0

I have the need to store the first half of a URL inside a variable which will be used later when running other commands. Does anyone know a method to extract the first part of the URL and ignore everything after the delimiter ?

I was thinking something similar to this but instead of storing everything after the delimiter, store the value before.

javascript{storedVars['MyVariable'].split('=')[storedVars['delimiter']]}

The format of the URL is similar to the following...

mywebsite.ca/cms/One.aspx?objectId=145655&contextId=1320565&parentId=1274179

The desired result would be to store mywebsite.ca/cms/One.aspx?objectId=145655 inside a variable.

Update:

I was able to solve my problem by referencing this post

Extract part of a text with selenium IDE and put it into variable

Thank you

Community
  • 1
  • 1
CJL22
  • 1
  • 1

1 Answers1

0
javascript{storedVars['MyVariable'].split('&')[0]}

I think this is what you want. This will split on the parameters (&) but allow you to capture the capture "mywebsite.ca/cms/One.aspx?objectId=145655" from "mywebsite.ca/cms/One.aspx?objectId=145655&contextId=1320565&parentId=1274179"

You might be well served by reading this: Break a URL into its components

Community
  • 1
  • 1
DMart
  • 2,401
  • 1
  • 14
  • 19