Open function no longer working for Relative Paths

Code snippet:
{
“Command”: “open”,
“Target”: “/a42/o”,
“Value”: “”
},

This used to work just fine, but for some reason nothing happens anymore. I use the same code in multiple different environments/sandboxes along the way, so I really need the relative path appended to the existing URL functionality to work.

“Note: If the OPEN argument does not start with http:// or https:// (e. g. “OPEN | /contact”), then UI.Vision RPA assumes this is a relative path it is appended to the existing URL.”
-Open - Selenium IDE Commands Tutorial

I confirmed this issue. For now, please use absolute paths.

It doesn’t make sense for me to use absolute paths because I create the cases in one environment and then they are used in multiple different environments by different users. Is there a workaround for this? Can I somehow grab the existing URL and then append the relative path to it in a string and use that for the “Open…” command?

Yes, you can. See here:

Here’s my solution. I created a new case called “GetUrl.” You will most likely have to do something slightly different with the RegEx, but this is a start. (This should work with all Salesforce sandboxes). Then in each of my test cases I call “Run /GetUrl” at the beginning and then I have access to "${global_baseUrl}. Example of that in action below.

{
  "Name": "GetUrl",
  "CreationDate": "2021-4-21",
  "Commands": [
    {
      "Command": "executeScript",
      "Target": "var currentPage = window.location.href; return currentPage;",
      "Value": "currentPage"
    },
    {
      "Command": "echo",
      "Target": "${currentPage}",
      "Value": ""
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "var currPage = ${currentPage};\nvar baseUrl = currPage.match(/https:\\/{2}[^\\/]+\\//);\nreturn baseUrl;",
      "Value": "global_baseUrl"
    },
    {
      "Command": "echo",
      "Target": "${global_baseUrl}",
      "Value": ""
    }
  ]
}

Example in use

{
  "Command": "run",
  "Target": "/Reuse/GetUrl",
  "Value": ""
},
{
  "Command": "open",
  "Target": "${global_baseUrl}a42/o",
  "Value": ""
},
1 Like