Selenium IDE (Chrome): Execute Script fails if variable value has a line break

233 views
Skip to first unread message

Andy

unread,
Jan 17, 2019, 6:47:02 AM1/17/19
to Selenium Users

I'm using Selenium IDE v3.4.4 in Chrome. I'm using the 'store text' to store an address (with line breaks) as a variable then running 'execute script' on that variable I get the error: Failed: Invalid or unexpected token

Html is like:

<tr>
  <td>Address</td>
  <td>
    <span>"Unit 1"
    <br>
    "South Street"
    <br>
    "London"
    </span>
  </td>
</tr>

Command: store text
target: xpath=//tr[td='Address']/td[2]/span
value: custAdd

Command: execute script
target: return ${custAdd}.replace(String.fromCharCode(10),' ')
Value: CustAdd

I get the error. Failed: Invalid or unexpected token


What does work:

Without doing the 'execute script' I can use the variable with the 'type' command.

I can do the 'execute script' command on any other stored variable that has no line breaks.

I would expect this to work (it has done in an old version of selenium 2.9.1 on firefox).

Yannick Rasmussen

unread,
Mar 20, 2020, 2:43:41 AM3/20/20
to Selenium Users
I have the exact same problem. Did you find a solution for this?
Reply all
Reply to author
Forward
0 new messages