Jump to content

XPath can't be found

Recommended Posts


on a website with the source code I attached I tried to press the "Einverstanden" button automatically.

But I always get the message "Unable to locate element"

These are my three different attempts to click on the "Einverstanden" button:

;Full XPath: /html/body/div/div[2]/div/div/div[2]/div/div/button
;Unable to locate element: {\"method\":\"xpath\",\"selector\":\"//html/body/div/div[2]/div/div/div[2]/div/div/button\"}\n
Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//html/body/div/div[2]/div/div/div[2]/div/div/button")

;XPath: //*[@id="onetrust-accept-btn-handler"]
;Unable to locate element: {\"method\":\"xpath\",\"selector\":\"//*[@id='onetrust-accept-btn-handler']\"}
Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='onetrust-accept-btn-handler']")

;Unable to locate element: {\"method\":\"xpath\",\"selector\":\"//button[@id='onetrust-accept-btn-handler']\"}
;Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@id='onetrust-accept-btn-handler']")
_WD_ElementAction($sSession, $sElement, 'click')

This is the source code of the website:


So what can be wrong and what have I to do to click on the "Einverstanden" button automatically?

Edited by AI123
Link to post
Share on other sites

I tried now this:

Local $sFrame = _WD_FrameEnter($sSession, "//*[@id='sprd-consent'")
; and tried this Local $sFrame = _WD_FrameEnter($sSession, "sprd-consent")

Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='onetrust-accept-btn-handler']")


But it seems the frame can't be found:

_WD_Navigate: {"value":null}
__WD_Post: URL=HTTP://; $sData={"id":{"element-6066-11e4-a52e-4f735466cecf":"//*[@id='sprd-consent'"}}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n  (Ses...

If I imagine right there is a website where all _WD_ function parameters are described. But now I only can find this.


But there the function parameter are not described. So can you or someone please say me where I can find the website where _WD_ functions and parameters are described?

Update: Have found it. Parameters are described at the bottom of the https://github.com/Danp2/WebDriver page.

So could it be I use a wrong parameter in _WD_FrameEnter?

Edited by AI123
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...