Jump to content

Can't reach XPath with _WD_FindElement


AI123
 Share

Recommended Posts

Hello, on a website there is this given input field that I want to fill out automatically:

<div class="input textarea clearfix" id="secondary_tags" data-original-title="" title="">
  ::before
  <span class="taggle_placeholder" style="opacity: 1;">bla</span>
  <ul class="taggle_list">
    <li>
      <input type="text" class="taggle_input ui-autocomplete-input" tabindex="4" maxlength="100" autocomplete="off"
      style="padding-left: 0px; padding-right: 0px; width: 10px;">
    </li>
  </ul>
</div>

The Google developer tools say this is the XPath:

//*[@id="secondary_tags"]/ul[1]/li/input

 

So I tried to fill the field with this code:

...
$sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='secondary_tags']/ul[1]/li/input")
_WD_ElementAction($sSession,$sButton,'value', 'tags')
...

But I got this error messages:

...
$sData={"using":"xpath","value":"//input[@id='secondary_tags']/ul[1]/li/input"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element:
Unable to locate element: {\"method\":\"xpath\",\"selector\":\"//input[@id='secondary_tags']/ul[1]/li/input\"}\n
...

So I tried it this way:

...
$sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='secondary_tags']")
_WD_ElementAction($sSession,$sButton,'value', 'tags')
...

But then I got this error messages:

$sData={"using":"xpath","value":"//input[@id='secondary_tags']"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element:
Unable to locate element: {\"method\":\"xpath\",\"selector\":\"//input[@id='secondary_tags']\"}\n

Does anybody know what's wrong and what have I to change?

Edited by AI123
Link to comment
Share on other sites

8 minutes ago, AI123 said:

$sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='secondary_tags']")

This won't work because that ID belongs to the div, not the input element. You could try this instead --

$sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='secondary_tags']/input")

 

Link to comment
Share on other sites

11 minutes ago, Danp2 said:

This won't work because that ID belongs to the div, not the input element. You could try this instead --

$sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='secondary_tags']/input")

 

Thank you for your advice, it doesn't work yet but with this change it works:

$sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='secondary_tags']/ul/li/input")

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...