Jump to content

_WD_FindElement does match the given locator text on the web page when using Edge browser.


Dmp
 Share

Go to solution Solved by Danp2,

Recommended Posts

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.

    ; 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)

 

SelectorHub.PNG

Link to comment
Share on other sites

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. 

Func 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"

 

NextButtonUse.PNG

LoginButtonUse.PNG

Link to comment
Share on other sites

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 by Danp2
Link to comment
Share on other sites

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

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?

Link to comment
Share on other sites

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

  • Solution

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

 

Link to comment
Share on other sites

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

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...