Jump to content

Can a variable be used within the syntax pertaining to $_WD_LOCATOR_ByXPath?


Recommended Posts

Hello,

I am new to this forum and to Autoit, therefore, if you would please pardon my ignorance.

I have multiple items, or nodes, in a webpage that I am trying to click on, one right after another, and I am hoping that I can loop through an "array For statement" in order to use the array's element variable as a substitute where the xpath syntax is unique to each item.

Unfortunately, what I have tried has not worked; see code below.

This is the xpath that I've been given from SelectorsHub: (... "//div[@class='leaflet-marker-pane']//div[1]").

Each item has a different numerical value at the very of the //div expression: //div[1]") , or  //div[2]"),  //div[17]"), etc.

Is there a way to use a variable within the xpath syntax?

 

                Local $iMax
                Local $sData = "1,2,3,4,5,6,7,8,9,10,11,12,1,14,15,16,17,18,19,20,21,22,23,24,26,27,28,29,30,31,32,33"

                Local $aDiv = StringSplit($sData, ",")


                If IsArray($aDiv) Then
                    _ArrayDisplay($aDiv)
                    $iMax = UBound($aDiv)


                    For $i = 0 to $iMax -1

                        Local $iElmnt = $aDiv[$i]
                        ; MsgBox($MB_SYSTEMMODAL, "Var", "Var is: " & $iElmnt, 5)

                        $sFElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@class='leaflet-marker-pane']//div[$iElmnt]")
                        _WD_ElementAction($sSession, $sFElement, 'click')
                        Sleep(2000)
                    Next
                EndIf

 

Link to post
Share on other sites

Thank you so much for your response and in showing me what I needed to do to make it work!

I have been reading these forums for a while now and am very impressed w/ the content and the considerable support given to the participants. 

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