I am trying to get the current page’s URL with the following code:
{
"Name": "TEST",
"CreationDate": "2020-8-23",
"Commands": [
{
"Command": "store",
"Target": "${!URL}",
"Value": "current_url"
}
]
}
It throws an error
It says “Internal variable “!URL” not supported”. I’ve tried searching through this forum but not finding the right solution.
After getting that URL I want to apply a regex to it:
current_url.regex("/.com/(\w+)/")
Is there any way to apply a regex to an existing variable? I’m not finding any way to achieve this. All ways of applying the regex is on the source code.
Can someone please help me out with this?
To use command ${!URL} you must load before the url, after it works.
I use alternative solution to save current url in any time
{
"Name": "Save_Current_Url",
"CreationDate": "2020-8-23",
"Commands": [
{
"Command": "executeScript",
"Target": "return (window.location.href)",
"Value": "executeScript_Sandbox_result"
},
{
"Command": "echo",
"Target": "${executeScript_Sandbox_result}",
"Value": ""
}
]
}
3 Likes
This works great. Thanks for replying!
AdelieN
September 23, 2020, 12:12pm
4
Hello,
I tried to use your solution to get el current url page, but it get the ui.vision popup url instead of the current url webpage tested ! How can I do to get the url webpage and not the ui.vision url please ?
{
“Command”: “executeScript_Sandbox”,
“Target”: “var currentPage = window.location.href; return currentPage;”,
“Value”: “currentPage”
},
{
“Command”: “echo”,
“Target”: “${currentPage}”,
“Value”: “”
}
I use this code and working
{
"Name": "Save_Current_Url",
"CreationDate": "2020-9-23",
"Commands": [
{
"Command": "executeScript",
"Target": "return (window.location.href)",
"Value": "executeScript_Sandbox_result"
},
{
"Command": "echo",
"Target": "${executeScript_Sandbox_result}",
"Value": ""
}
]
}
newuserkantu:
{
"Name": "Save_Current_Url",
"CreationDate": "2020-9-23",
"Commands": [
{
"Command": "executeScript",
"Target": "return (window.location.href)",
"Value": "executeScript_Sandbox_result"
},
{
"Command": "echo",
"Target": "${executeScript_Sandbox_result}",
"Value": ""
}
]
}
I want to use this script for Pinterest, but Pinterest blocks executeScript
. How could I use it with executeScript_Sandbox
? @newuserkantu @admin @ulrich
If executeScript_Sandbox
is blocked then you will need to load the website in the tab first, such as executing open
, then accessing !URL
will work.