xPath in executeScript_Sandbox

Given a command that fetches content from a loaded web page using xpath:

    {
      "Command": "storeText",
      "Target": "xpath=/html/body/div[3]/div/div[2]/div[9]/div/div/div/div/div/div[2]/div",
      "Value": "test"
    }

I want to be able to fetch the same content from within executeScript_Sandbox with javascript:

x = document.evaluate(’/html/body/div[3]/div/div[2]/div[9]/div/div/div/div/div/div[2]/div’, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue

Obviously I am addressing the ui.vision plugin, not the loaded web page. How would I do that?

With the command executeScript_Sandbox you are not able to retrieve objects from the WebPage because you are in a Sandbox, Javascript is running in a “Limbo” not in the page. If you want to retrieve objects with xPath you need to use executeScript, not executeScript_Sandbox

1 Like

Thank you , works like a charm.

  • In contrast to the sandbox version, the output of console.log() will be in the web page window’s inspector, not the uivision’s.
  • To address something like a text use x.firstChild.textContent
  • to see all addressable attribute fields of the object, echo the object with console.log(x) and inspect it.