Dmp Posted September 20, 2023 Share Posted September 20, 2023 Hello WD UDF Team... I'm using Edge browser and I'm trying to find and click on the password textbox on a web login page, but _WD_FindElement does match the given locator text on the web page. I used SelectorsHub to inspect the page. BTW, the very same _WD_FindElement line w/ xPath works on Chrome. I attached an image of SelectorsHub inspection. expandcollapse popup ; Locate the "Password" text field after Username input. then clicking on the Next button. ; Local $sElePsswd = _WD_FindElement($WD_SESSION, $_WD_LOCATOR_ByXPath, "//input[@id='Password']", Default, Default, BitOR($_WD_OPTION_Visible, $_WD_OPTION_Enabled)) ; Local $sElePsswd = _WD_FindElement($WD_SESSION, $_WD_LOCATOR_ByCSSSelector, "#Password") Local $sElePsswd = _WD_FindElement($WD_SESSION, $_WD_LOCATOR_ByXPath,"//input[@id='Password']") ; _WD_WaitElement($WD_SESSION, $_WD_LOCATOR_ByXPath, "//input[@id='Password']", Default, Default, 2) -----------------BELOW "NO MATCH" OUTPUT IS FOR Strategy=css selector Selector=#Password... _WD_FindElement ==> Success [0] : Parameters: Strategy=xpath Selector=//input[@id='UserName'] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_ElementAction ==> Success [0] : Parameters: Command=value Option=<masked> __WD_Post ==> Success [0] : HTTP status = 200 _WD_FindElement ==> Success [0] : Parameters: Strategy=xpath Selector=//input[@id='submitlogin'] StartNodeID=Default Multiple=Default ShadowRoot=Default _WD_WaitElement ==> Success [0] : Parameters: Strategy=xpath Selector=//input[@id='submitlogin'] Delay=Default Timeout=Default Options=2 __WD_Post ==> Success [0] : HTTP status = 200 _WD_ElementAction ==> Success [0] : Parameters: Command=click Option=Default __WD_Post ==> No match [8] : HTTP status = 404 _WD_FindElement ==> No match [8] : Parameters: Strategy=css selector Selector=#Password StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> No match [8] : HTTP status = 404 _WD_ElementAction ==> No match [8] : Parameters: Command=click Option=Default _WD_LoadWait ==> Success [0 / 4] : Parameters: Delay=2000 Timeout=Default Element=Default DesiredState=complete : ReadyState= complete (Fully loaded) _WD_WaitElement ==> Invalid Expression [11] : Parameters: Strategy=xpath Selector= Delay=Default Timeout=Default Options=2 __WD_Post ==> No match [8] : HTTP status = 404 _WD_ElementAction ==> No match [8] : Parameters: Command=value Option=<masked> __WD_Post ==> No match [8] : HTTP status = 404 _WD_ElementAction ==> No match [8] : Parameters: Command=value Option=<masked> -----------------BELOW "NO MATCH" OUTPUT IS FOR Strategy=xpath Selector=//input[@id='Password']... _WD_FindElement ==> Success [0] : Parameters: Strategy=xpath Selector=//input[@id='UserName'] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_ElementAction ==> Success [0] : Parameters: Command=value Option=<masked> __WD_Post ==> Success [0] : HTTP status = 200 _WD_FindElement ==> Success [0] : Parameters: Strategy=xpath Selector=//input[@id='submitlogin'] StartNodeID=Default Multiple=Default ShadowRoot=Default _WD_WaitElement ==> Success [0] : Parameters: Strategy=xpath Selector=//input[@id='submitlogin'] Delay=Default Timeout=Default Options=2 __WD_Post ==> Success [0] : HTTP status = 200 _WD_ElementAction ==> Success [0] : Parameters: Command=click Option=Default __WD_Post ==> No match [8] : HTTP status = 404 _WD_FindElement ==> No match [8] : Parameters: Strategy=xpath Selector=//input[@id='Password'] StartNodeID=Default Multiple=Default ShadowRoot=3 __WD_Post ==> No match [8] : HTTP status = 404 _WD_ElementAction ==> No match [8] : Parameters: Command=click Option=Default _WD_LoadWait ==> Success [0 / 4] : Parameters: Delay=2000 Timeout=Default Element=Default DesiredState=complete : ReadyState= complete (Fully loaded) Link to comment Share on other sites More sharing options...
Danp2 Posted September 20, 2023 Share Posted September 20, 2023 You didn't post the full code, so it's difficult to know for sure what is supposed to be happening. It appears that you are clicking the submitlogin element before you attempt to locate the password element. Is that intended? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Dmp Posted September 21, 2023 Author Share Posted September 21, 2023 Good question regarding the "submitlogin" element. There are 2 of these element used in the login process; the only difference between the two is the associated text. After the userName element is filled out, the "Next" button (submitlogin element) needs to be clicked to go on to the page displaying the Password textbox and Login button. The "submitlogin" element click you mentioned belongs to clicking the Next button. This is working w/out issues; however, trying to get a match for the Password element using _WD_FindElement is where I'm having an issue. I've attached the SelectorsHub info on the 2 "submitlogin" elements to better explain the set-up. I've looked wd_core for other Strategy options, but neither have worked: _WD_LOCATOR_ByLinkText, ..._ByPartialLinkText, ..._ByTagName. expandcollapse popupFunc VPLogin() ; VP login: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Local $sEmailAddress = 'XXXXX@xxx.com' Local $sElement = _WD_FindElement($WD_SESSION, $_WD_LOCATOR_ByXPath, "//input[@id='UserName']") Do Local $eaElement = _WD_ElementAction($WD_SESSION, $sElement, 'value', $sEmailAddress) $iResultUNme = @error Until $iResultUNme = $_WD_ERROR_Success ; Locate the "Next" button after Username input Local $sElement2 = _WD_FindElement($WD_SESSION, $_WD_LOCATOR_ByXPath, "//input[@id='submitlogin']") _WD_WaitElement($WD_SESSION, $_WD_LOCATOR_ByXPath, "//input[@id='submitlogin']", Default, Default, 2) ; MsgBox($MB_SYSTEMMODAL, "", "Wait ended for Submit Login id", 5); For testing _WD_ElementAction($WD_SESSION, $sElement2, 'click') ; _WD_LoadWait($WD_SESSION, 2000) ; Locate the "Password" text field after Username input. then clicking on the Next button. ; Local $sElePsswd = _WD_FindElement($WD_SESSION, $_WD_LOCATOR_ByXPath, "//input[@id='Password']", Default, Default, BitOR($_WD_OPTION_Visible, $_WD_OPTION_Enabled)) ; Local $sElePsswd = _WD_FindElement($WD_SESSION, $_WD_LOCATOR_ByCSSSelector, "#Password") Local $sElePsswd = _WD_FindElement($WD_SESSION, $_WD_LOCATOR_ByXPath,"//input[@id='Password']") ; _WD_WaitElement($WD_SESSION, $_WD_LOCATOR_ByXPath, "//input[@id='Password']", Default, Default, 2) ; _WD_ElementAction($WD_SESSION, $sElePsswd, 'click') ; Used as Reference to try different locator options ; //input[@id='Password'] ; (//input[@id='Password'])[1] ; #Password ; Global Const $_WD_LOCATOR_ByCSSSelector = "css selector" ; Global Const $_WD_LOCATOR_ByXPath = "xpath" ; Global Const $_WD_LOCATOR_ByLinkText = "link text" ; Global Const $_WD_LOCATOR_ByPartialLinkText = "partial link text" ; Global Const $_WD_LOCATOR_ByTagName = "tag name" Link to comment Share on other sites More sharing options...
Danp2 Posted September 21, 2023 Share Posted September 21, 2023 (edited) 3 hours ago, Dmp said: ; Locate the "Next" button after Username input Local $sElement2 = _WD_FindElement($WD_SESSION, $_WD_LOCATOR_ByXPath, "//input[@id='submitlogin']") _WD_WaitElement($WD_SESSION, $_WD_LOCATOR_ByXPath, "//input[@id='submitlogin']", Default, Default, 2) You should be able to eliminate the call to _WD_FindElement -- ; Locate the "Next" button after Username input Local $sElement2 = _WD_WaitElement($WD_SESSION, $_WD_LOCATOR_ByXPath, "//input[@id='submitlogin']", Default, Default, 2) You may want to try the same thing with your _WD_FindElement that is failing -- _WD_ElementAction($WD_SESSION, $sElement2, 'click') ; Locate the "Password" text field after Username input. then clicking on the Next button. Local $sElePsswd = _WD_WaitElement($WD_SESSION, $_WD_LOCATOR_ByXPath, "//input[@id='Password']", Default, Default, 2) Edited September 21, 2023 by Danp2 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Dmp Posted September 21, 2023 Author Share Posted September 21, 2023 Unfortuntely, not finding and clicking the "Next" button element does not enable the display of the Password element and the Login button. Not knowledgeable in these matters, but it’s as though a sub-display is loaded when the Next button is clicked---is this a Shadow Dom? Is the “2” value in the shadowRoot parameter in: _WD_FindElement ($WD_SESSION, $_WD_LOCATOR_ByXPath, "//input[@id='Password']", Default, Default, 2) a positional indicator? I commented out all the _WD_LoadWait_ lines, but I'm still getting the same: __WD_Post ==> No match [8] : HTTP status = 404 _WD_FindElement ==> No match [8] : Parameters: Strategy=xpath Selector=//input[@id='Password'] StartNodeID=Default Multiple=Default ShadowRoot=2 Link to comment Share on other sites More sharing options...
Dmp Posted September 21, 2023 Author Share Posted September 21, 2023 Should I be looking at including a line as such for the Password element? $sRoot = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByCSSSelector, "#usercentrics-root") Link to comment Share on other sites More sharing options...
Danp2 Posted September 21, 2023 Share Posted September 21, 2023 I never said that you should skip clicking the Next button. I simply showed how you could use _WD_WaitElement to obtain the element ID. 26 minutes ago, Dmp said: Is the “2” value in the shadowRoot parameter in: _WD_FindElement ($WD_SESSION, $_WD_LOCATOR_ByXPath, "//input[@id='Password']", Default, Default, 2) a positional indicator? No, this syntax is incorrect (_WD_WaitElement and _WD_FindElement don't use the same syntax). See the help file for more info. I don't think you are dealing with a shadow root. Can you share the site's URL so that I can take a look? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Dmp Posted September 22, 2023 Author Share Posted September 22, 2023 I was actually referring to the Syntax ........: _WD_FindElement($sSession, $sStrategy, $sSelector[, $sStartNodeID = Default[, $bMultiple = Default[, $bShadowRoot = Default]]]) I thought perhaps rather than $bShadowRoot = Ture, a numerical value was a valid input in some manner. W/ Chrome, this line: Local $sElePsswd = _WD_FindElement($WD_SESSION, $_WD_LOCATOR_ByXPath,"//input[@id='Password']") has been working perfectly for some time, however, I now need to use Edge. I’ve only just started the transition to Edge, and I’m only having an issue w/ the Password element on the login page. Using _WD_FindElement with XPath works fine w/ all the other elements on the page. The url for the login page is https://apps.id-systems.com Link to comment Share on other sites More sharing options...
Solution Danp2 Posted September 22, 2023 Solution Share Posted September 22, 2023 No, $bShadowRoot only takes a boolean value. I can't explain why you are experiencing different behaviors while using Edge, but then again it is Microsoft. 🙄 I looked at the site and don't see any shadow roots. It does look like they are dynamically loading elements, so I would suggest using _WD_WaitElement like this -- ; Locate the "Next" button after Username input Local $sElement2 = _WD_WaitElement($WD_SESSION, $_WD_LOCATOR_ByXPath, "//input[@id='submitlogin']", Default, Default, $_WD_OPTION_Enabled + $_WD_OPTION_Visible) _WD_ElementAction($WD_SESSION, $sElement2, 'click') ; Locate the "Password" text field after Username input. then clicking on the Next button. Local $sElePsswd = _WD_WaitElement($WD_SESSION, $_WD_LOCATOR_ByXPath, "//input[@id='Password']", Default, Default, $_WD_OPTION_Enabled + $_WD_OPTION_Visible) If @error = $_WD_ERROR_Success Then _WD_ElementAction($WD_SESSION, $sElePsswd, 'value', $sYourPassword) Else ConsoleWrite("! Password element not found!" & @CRLF) EndIf Dmp 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Dmp Posted September 22, 2023 Author Share Posted September 22, 2023 That did it... earlier, I had tried "$_WD_OPTION_Enabled" or $_WD_OPTION_Visible using BitOr, but for "_WD_FindElement," which didn't work, needless to say. Thank you again for another solution and insight into the WD tools.🙂👍 Link to comment Share on other sites More sharing options...
Danp2 Posted September 22, 2023 Share Posted September 22, 2023 You're welcome! Latest Webdriver UDF Release Webdriver Wiki FAQs 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