0

I am having with an issue with a regular expression

storeLocation | CurrentUrl
storeEval     | re=/https://[.\w-]+/[.\w-]*\//;re.exec(${CurrentUrl})   |  jsHostName

it gives this error:

[error] Threw an exception: missing ) after argument list 

Note: I am noticing that Selenium IDE puts in extra slashes after I move the cursor to the text box that contains all the IDE commands I have entered.

storeEval     | re=/https://[.\\w-]+/[.\\w-]*\\//;re.exec(${CurrentUrl})  |  jsHostName
2
  • storeEval is on a separate line from storeLocation.. I'm not use to stackoverflow's editor. Commented Jun 6, 2011 at 15:29
  • I fixed that for you. For future reference, see: stackoverflow.com/editing-help Commented Jun 6, 2011 at 15:55

2 Answers 2

3

${CurrentUrl} returns the value of a variable as literal text, but since you want to work with the variable in javascript, you need to access it through the storedVars array. Hence, if you change your script to the following it should work:

re=/…/; re.exec(storedVars["CurrentUrl"])
Sign up to request clarification or add additional context in comments.

Comments

0

Your regular expression is not valid: in JavaScript context (since, as you likely know, the argument to storeEval is a JavaScript expression) the general form of this shorthand constructor for a regular expression object is:

<variable> = / <your-regex> /

The important implication is that <your-regex> may not contain any virgules (/), unless you properly escape them with backslashes. You have done this for the final virgule in your expression but you have to do it for each of them, hence I have added three backslashes to get this:

re = /https:\/\/[.\w-]+\/[.\w-]*\//;

Note that you can even validate your regex right here on SO(!): Look at your initial code fragment and you will see that just /https:/ is highlighted in burgundy; with my code fragment just above the entire right-hand-side is highlighted in burgundy.

This fix should get you farther; have not checked it in Selenium to see if it resolves your entire issue.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.