Insert Variable Inside String Issue

Hello,

I’m having an issue inserting a variable into a string that has a dash sign. Kantu/selenium I believe thinks the dash is a minus sign and therefore it’s not working. The “A” at the end of the string is my variable. The xpath is as follows:

//*[@id=“inputInfringingElement-${A}”]

This results in an error and it shows that the variable didn’t get inserted (says it fails to find //*[@id=“inputInfringingElement-${A}”]). But if I put like a space inbetween - and ${A} it will insert the variable but it still fails to find the xpath because now there’s that space. Might be something really stupid but I can’t figure out how to get it to work.

Thanks!

I did a quick test and the var replacement works for me:

This is what happens for me…this is when I don’t insert a space. It just does ${A} and says "option type " " not supported

Then it works if I insert a space (but again it won’t find it because now there’s that space)

Well, in my case I have no space and it still replaces the variable ok. It does not find the element, because I run it on a different website, since I do not have the URL of your website.

So I can get it to work with no space just doing something like you did using 123 or ABC.
But the issue comes when I’m storing a value like the following: B002WJFRTG
Then it won’t work for whatever reason. Except if I remove the “G” off the end, then it works. So I have no idea what’s going on.

That is really strange. I tested with B002WJFRTG and the macro above and all works. => Does the test macro from above work for you?

Yeah it did, so I deleted the lines of code I had written and tried again and now it’s working. I have no idea why it wasn’t before but thank you for your help.

Also, any word on the pausing issue? Ever since the last update when I run macros that take several minutes to complete, they will often stop (no errors, they just stop). Hitting pause/resume will get them going again but it’s pretty annoying.

Can you please make a new forum post for this topic? Ideally with a test macro. For example, if you do a simple macro with a long PAUSE command, do you see this issue, too? (I tested with a 300 seconds pause and all worked fine)

Started a new thread. Thanks!

https://forum.a9t9.com/t/pausing-stopping-issue/703

Insert text = Split string + Append string again

See also Selenium IDE string operations with executeScript_Sandbox