AI123 Posted September 5, 2019 Share Posted September 5, 2019 (edited) 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 September 5, 2019 by AI123 Link to comment Share on other sites More sharing options...
Danp2 Posted September 5, 2019 Share Posted September 5, 2019 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") AI123 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
AI123 Posted September 5, 2019 Author Share Posted September 5, 2019 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") Danp2 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now