Open function no longer working for Relative Paths

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