Open URL based on current URL

I would like to after opening an URL (manually), open another one in another tab based on that one.

Starting point:
Result URL after searching for (manually), “TP” “237” for today:
Automated URL based on this one (because I don’t always want to check it):

I thought of 2 choices:

  • Find a way for the second url to grab some variables from the 1st and join with the value grabbed from Html (“LIS”)
  • Store some variables of the first URL (like departure “LIS” and the date - although I’m not sure how could I transform “Oct” into “10”) and then go through the all process of going to the website, insert these values and then get the results (using kantu of course, not manually)

Not sure how to accomplish the 1st one at all and also not sure what would be the best approach in general.
Am I seeing this wrong?

  1. Get the current URL with the ${!url} variable

  2. Apply some Javascript and maybe regular expressions to extract the values you need from the URL. Use the execute script (sandbox) command for this.

  3. Build the new URL, and use OPEN | ${newurl}

1 Like

Thank you. I’m going to try and come back with results


“Name”: “FS”,
“CreationDate”: “2020-10-30”,
“Commands”: [
“Command”: “selectWindow”,
“Target”: “tab=0”,
“Value”: “”
“Command”: “store”,
“Target”: “{!URL}", "Value": "initialurl" }, { "Command": "comment", "Target": "echo // {initialurl}”,
“Value”: “”
“Command”: “storeText”,
“Target”: “xpath=//*[@id=“content”]/div/div/main/div/div/section/div[2]/div/div/div/div/h2”,
“Value”: “departure”
“Command”: “selectWindow”,
“Target”: “TAB=OPEN”,
“Value”: “${departure}/2020/10/17

I’ve also came up with the regex:


Currently, I grab the full initial URL, grab a bit from the webpage and then open in a new TAB another URL using the bit grabbed from the webpage. I need to grab the date from the initial URL to also use in the new one. The regex does grab that, I just don’t know how to use it in Kantu…

Can anyone give me a hand?
Thanks in advance

You can run any Javascript including regexp with the execute Script Selenium IDE command.

Hint: In your case better use the executescript_Sandbox version since your script does not need web page access.

My regex changed and had one last push in another forum but I’ve came up with this, for the javascript:

“Command”: “executeScript_Sandbox”,
“Target”: “var myRe = /\d{4}\/\d{1,2}\/\d{1,2}/;\nvar myArray = myRe.exec(’${initialurl}’); return myArray”,
“Value”: “initialurl”

and it works.