Jump to content
Danp2

WebDriver UDF - Help & Support

Recommended Posts

@Danp2 I have tried command a. to c. out of success. Your command d. was successful !

a.      $sValue = _WD_ElementAction($sSession, $aOptions[$i], 'value')

b.      $sValue = _WD_ElementAction($sSession, $aOptions[$i], 'property')

c.      $sValue = _WD_ElementAction($sSession, $aOptions[$i], 'attribute')

d.      $sValue = _WD_ElementAction($sSession, $aOptions[$i], 'attribute', 'value')

 

Many thanks.

Share this post


Link to post
Share on other sites
<tr>
</tr>
<tr>
</tr>
<tr data-id="0" class="even">
</tr>
<tr data-id="1" class="even">
</tr>
<tr data-id="2" class="even">
</tr>
<tr data-id="3" class="even">
</tr>
<tr data-id="4" class="even">
</tr>
<tr>
</tr>
<tr>
</tr>

Is it possible to find all the elements table rows with the attribut/property "data-id" with the function _WD_FindElement ?

 

<input id="SopEmployee_status" name="SopEmployee[status]" value="ALL" type="checkbox" checked>

LAST question for today: How can I check if a CheckBox like that is checked or not ?

Many thanks in advance.

Share this post


Link to post
Share on other sites
45 minutes ago, Hamburgo said:

Is it possible to find all the elements table rows with the attribut/property "data-id" with the function _WD_FindElement ?

Yes, it should be possible with the appropriate xpath selector. What have you tried thus far?

46 minutes ago, Hamburgo said:

How can I check if a CheckBox like that is checked or not ?

http://bfy.tw/NWSU

:thumbsup:

Share this post


Link to post
Share on other sites
7 minutes ago, Danp2 said:

Yes, it should be possible with the appropriate xpath selector. What have you tried thus far?

I am tried nothing, because I do not found anything about that on https://devhints.io/xpath
So I have no idea what can be the syntax.

 

Share this post


Link to post
Share on other sites
15 hours ago, Hamburgo said:

I am tried nothing, because I do not found anything about that on https://devhints.io/xpath
So I have no idea what can be the syntax.

 

answer by myself:

$aTableRows = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//tr", '', True)

    _ArrayDisplay($aTableRows, "a. Table-Rows:")

    $aTableRows = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//tr[@data-id]", '', True)

    _ArrayDisplay($aTableRows, "b. Table-Rows[@data-id]:")

    $aTableRows = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//tr[@data-id='2']", '', True)

    _ArrayDisplay($aTableRows, "c. Table-Rows[@data-id='2']:")


 

Share this post


Link to post
Share on other sites
15 hours ago, Danp2 said:

Yes, it should be possible with the appropriate xpath selector. What have you tried thus far?

http://bfy.tw/NWSU

:thumbsup:

this works for me:

     $sValue = _WD_ElementAction($sSession, $sCheckBox, 'selected')

 

Share this post


Link to post
Share on other sites

Hi Dan,

Great Thanks for your help.
 

I improved the function : as you can see i replaced the "StartElement" parameter by an  option value parameter (that i did not understood well sorry...)

The option value parameter is the value you want to select on your listbox.


You Can try the new function on the demo code  and improve it for sure :)

 

Func DemoNavigation()


_WD_Window($sSession, "maximize")
_WD_Navigate($sSession, "https://www.nvidia.fr/Download/index.aspx?lang=fr")

_WD_OptionSelectElement($sSession, $_WD_LOCATOR_ByXPath, "//select[@id='selProductSeriesType']/option", "tesla")

EndFunc

The new function : 

Func _WD_OptionSelectElement($sSession, $sStrategy, $sSelector, $OptionValue)

    Local $aElements
    Local $DicElements
    Local $i
    Local $Rslt

    Local $sElement

    $DicElements = objcreate("Scripting.Dictionary")

;~     $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//select[@id='selProductSeriesType']/option", '', True)
    $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sSelector, '', True)

;~     _ArrayDisplay($aElements)


    For $i = 0 to Ubound($aElements) - 1

        $IdElement = $aElements[$i]

;~         print($IdElement)

        $TmpElement = _WD_ElementAction($sSession, $IdElement, 'text', 'value')
        $DicElements.Add(String($i),String($TmpElement))

;~         print($ValueElement)

    Next

    for $i = 1 To $DicElements.Count

        $TmpElement = $DicElements(String($i))

                if  $TmpElement = $OptionValue then

                    $Rslt = $i + 1
                    Exitloop

                Else

                    $Rslt = 0

                EndIf

    Next

    If $Rslt <> 0 Then

        $sElement = _WD_FindElement($sSession, $sStrategy, $sSelector & "[" & $Rslt & "]", "")

            If @error = $_WD_ERROR_Success Then
                _WD_ElementAction($sSession, $sElement, 'click')
            EndIf

    Else
             Consolewrite("Value : " & $OptionValue & " is not present on the element : " &  $sSelector &  "")

    EndIf

EndFunc

Share this post


Link to post
Share on other sites

Hi Dan,

I'm very glad with your UDF. All works pefectly, except for one thing:

I can not multiselect with xpath. The user does it pressing control and with the mouse, selects all desired options.

 I'm trying to do with the pipe:

Quote

 $searchForm = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body[@class=' app-users model-user change-form']/div[@id='container']/div[@id='content']/div[@id='content-main']/form[@id='user_form']/div/fieldset[@class='module aligned ']/div[@class='form-row field-groups']/div/div[@class='related-widget-wrapper']/select[@id='id_groups']/option[@value='1'] | /html/body[@class=' app-users model-user change-form']/div[@id='container']/div[@id='content']/div[@id='content-main']/form[@id='user_form']/div/fieldset[@class='module aligned ']/div[@class='form-row field-groups']/div/div[@class='related-widget-wrapper']/select[@id='id_groups']/option[@value='2'] ")

_WD_ElementAction($sSession, $searchForm, 'click')

But doesn't works.

Also i've tried to specify multiselection in _WD_FindElement, adding True, but didn't worked for me:

Quote

 $searchForm = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/select[@id='id_groups']/option[@value='1'] | /select[@id='id_groups']/option[@value='2'] ","",True)

_WD_ElementAction($sSession, $searchForm, 'click')

Or adding all atributes I want together, with and /or but didn't worked:

Quote

 $searchForm = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/select[@id='id_groups']/option[@value='1' | @value='2'] ","",True)

_WD_ElementAction($sSession, $searchForm, 'click')

Is there a way to do multiselect without using "send" autoit function for keypress?

Thanks and regards,

Share this post


Link to post
Share on other sites

20190507232420.png.6a521e01e675166cdceec4e8ee8a0f4a.png

 

As shown above, clicking on the sign in link will pop up a window-like page.

Please help me: how do I move from the original page to the newly pop-up window-like page and locate the elements?

My code is as follows:

#include "wd_core.au3"
#include "wd_helper.au3"
Local $url1 = "https://www.autoitscript.com/forum/"

Local $sDesiredCapabilities
_setupFirefox()
_WD_Startup()
Local $Session=_WD_CreateSession($sDesiredCapabilities)
Sleep(1000)
_WD_Navigate($Session, $url1)
Sleep(1000)

local $sSign_in=_WD_FindElement($Session, $_WD_LOCATOR_ByPartialLinkText,'Sign In')
_WD_ElementAction($Session,$sSign_in, 'click')
Sleep(500)

;Starting with the following code, there is no response and seems to remain on the original web page
local $uElement = _WD_FindElement($Session, $_WD_LOCATOR_ByXPath, '//*[@id="elUserSignIn_internal"]/div/ul/li[1]/input')
_WD_ElementAction($Session, $uElement, 'value', "username123")
Sleep(500)
local $pElement = _WD_FindElement($Session, $_WD_LOCATOR_ByXPath, '//*[@id="elUserSignIn_internal"]/div/ul/li[2]/input')
_WD_ElementAction($Session, $pElement, 'value', "Password321")
Sleep(500)

local $sElement = _WD_FindElement($Session, $_WD_LOCATOR_ByXPath, '//*[@id="elSignIn_submit"]')
_WD_ElementAction($Session, $sElement, 'click')

func _setupFirefox()
    $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}'
    _WD_Option('Driver', 'geckodriver.exe')
    _WD_Option('DriverParams', '--log trace')
    _WD_Option('Port', 4444)
EndFunc

 

Share this post


Link to post
Share on other sites
_WDStartup: OS:WIN_7 WIN32_NT 7601 Service Pack 1

    _WDStartup: AutoIt:3.3.14.2

    _WDStartup: WD.au3:0.1.0.17

    _WDStartup: Driver:geckodriver.exe

    _WDStartup: Params:--log trace

    _WDStartup: Port:4444

    __WD_Post: URL=HTTP://127.0.0.1:4444/session; $sData={"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}

    __WD_Post: StatusCode=200; ResponseText={"value":{"sessionId":"e7347278-b657-4bf8-8c8a-e01d6f4f0611","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"66.0.3","javascriptEnabled":true,"moz:accessibilityChecks":false,"moz:geckodriverVersion":"0.24.0","moz:headless":false,"moz:processID":5936,"moz:profile":"X:\\MESS\\TEMP\\user\\rust_mozprofile.SyLiP6uzUviF","moz:shutdownTimeout":60000,"moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"nativeEvents":true,"pageLoadStrategy":"normal","platformName":"windows","platformVersion":"6.1","rotatable":false,"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss  notify"}}}

    _WD_CreateSession: {"value":{"sessionId":"e7347278-b657-4bf8-8c8a-e01d6f4f0611","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"66.0.3","javascriptEnabled":true,"moz:accessibilityChecks":false,"moz:geckodriverVersion":"0.24.0","moz:headless":false,"moz:processID":5936,"moz:profile":"X:\\MESS\\TEMP\\user\\rust_mozprofile.SyLiP6uzUviF","moz:shutdownTimeout":60000,"moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"nativeEvents":true,"pageLoadStrategy":"normal","platformName":"windows","platformVersion":"6.1","rotatable":false,"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss  notify"}}}

    __WD_Post: URL=HTTP://127.0.0.1:4444/session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/url; $sData={"url":"https://www.autoitscript.com/forum/"}

    __WD_Post: StatusCode=200; ResponseText={"value":null}

    _WD_Navigate: {"value":null}

    __WD_Post: URL=HTTP://127.0.0.1:4444/session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/element; $sData={"using":"partial link text","value":"Sign In"}

    __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"17ba1cd7-e9a5-4701-b5a6-a6c0d32f8c6d"}}

    _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"17ba1cd7-e9a5-4701-b5a6-a6c0d32f8c6d"}}

    __WD_Post: URL=HTTP://127.0.0.1:4444/session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/element/17ba1cd7-e9a5-4701-b5a6-a6c0d32f8c6d/click; $sData={"id":"17ba1cd7-e9a5-4701-b5a6-a6c0d32f8c6d"}

    __WD_Post: StatusCode=200; ResponseText={"value":null}

    _WD_ElementAction: {"value":null}...

    __WD_Post: URL=HTTP://127.0.0.1:4444/session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/element; $sData={"using":"xpath","value":"//*[@id="elUserSignIn_internal"]/div/ul/li[1]/input"}

    __WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"Failed to decode request as JSON: {\"using\":\"xpath\",\"value\":\"//*[@id=\"elUserSignIn_internal\"]/div/ul/li[1]/input\"}","stacktrace":"语法错误 at :1:36"}}

    _WD_FindElement: {"value":{"error":"invalid argument","message":"Failed to decode request as JSON: {\"using\":\"xpath\",\"value\":\"//*[@id=\"elUserSignIn_internal\"]/div/ul/li[1]/input\"}","stacktrace":"语法错误 at :1:36"}}

    _WD_FindElement ==> Webdriver Exception: HTTP status = 400

    __WD_Post: URL=HTTP://127.0.0.1:4444/session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/element//value; $sData={"id":"", "text":"username123"}

    __WD_Post: StatusCode=404; ResponseText={"value":{"error":"unknown command","message":"POST /session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/element//value did not match a known command","stacktrace":""}}

    _WD_ElementAction: {"value":{"error":"unknown command","message":"POST /session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/el...

    _WD_ElementAction ==> Webdriver Exception: {"value":{"error":"unknown command","message":"POST /session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/element//value did not match a known command","stacktrace":""}}

    __WD_Post: URL=HTTP://127.0.0.1:4444/session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/element; $sData={"using":"xpath","value":"//*[@id="elUserSignIn_internal"]/div/ul/li[2]/input"}

    __WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"Failed to decode request as JSON: {\"using\":\"xpath\",\"value\":\"//*[@id=\"elUserSignIn_internal\"]/div/ul/li[2]/input\"}","stacktrace":"语法错误 at :1:36"}}

    _WD_FindElement: {"value":{"error":"invalid argument","message":"Failed to decode request as JSON: {\"using\":\"xpath\",\"value\":\"//*[@id=\"elUserSignIn_internal\"]/div/ul/li[2]/input\"}","stacktrace":"语法错误 at :1:36"}}

    _WD_FindElement ==> Webdriver Exception: HTTP status = 400

    __WD_Post: URL=HTTP://127.0.0.1:4444/session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/element//value; $sData={"id":"", "text":"Password321"}

    __WD_Post: StatusCode=404; ResponseText={"value":{"error":"unknown command","message":"POST /session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/element//value did not match a known command","stacktrace":""}}

    _WD_ElementAction: {"value":{"error":"unknown command","message":"POST /session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/el...

    _WD_ElementAction ==> Webdriver Exception: {"value":{"error":"unknown command","message":"POST /session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/element//value did not match a known command","stacktrace":""}}

    __WD_Post: URL=HTTP://127.0.0.1:4444/session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/element; $sData={"using":"xpath","value":"//*[@id="elSignIn_submit"]"}

    __WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"Failed to decode request as JSON: {\"using\":\"xpath\",\"value\":\"//*[@id=\"elSignIn_submit\"]\"}","stacktrace":"语法错误 at :1:36"}}

    _WD_FindElement: {"value":{"error":"invalid argument","message":"Failed to decode request as JSON: {\"using\":\"xpath\",\"value\":\"//*[@id=\"elSignIn_submit\"]\"}","stacktrace":"语法错误 at :1:36"}}

    _WD_FindElement ==> Webdriver Exception: HTTP status = 400

    __WD_Post: URL=HTTP://127.0.0.1:4444/session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/element//click; $sData={"id":""}

    __WD_Post: StatusCode=404; ResponseText={"value":{"error":"unknown command","message":"POST /session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/element//click did not match a known command","stacktrace":""}}

    _WD_ElementAction: {"value":{"error":"unknown command","message":"POST /session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/el...

    _WD_ElementAction ==> Webdriver Exception: {"value":{"error":"unknown command","message":"POST /session/e7347278-b657-4bf8-8c8a-e01d6f4f0611/element//click did not match a known command","stacktrace":""}}

Xpath is obtained through the developer tool F12 console.As an exercise,so take this forum login example. Dear Danp2, if you did this login, how would you write the code?More Thanks in advance!

Edited by Letraindusoir

Share this post


Link to post
Share on other sites

surely It seems that there's something wrong with the "xpath".It's like different browsers produce different xpath.:(

local $uElement = _WD_FindElement($Session, $_WD_LOCATOR_ByXPath, '/html/body/div[5]/form/div/div/div[1]/div/ul/li[1]/input')

local $pElement = _WD_FindElement($Session, $_WD_LOCATOR_ByXPath, '/html/body/div[5]/form/div/div/div[1]/div/ul/li[2]/input')

local $sElement = _WD_FindElement($Session, $_WD_LOCATOR_ByXPath, '//*[@id="elSignIn_submit"]')

now The errors that occur are as follows:

__WD_Post: URL=HTTP://127.0.0.1:4444/session/7c0c13f9-5c13-4851-9c47-365d0d196988/element; $sData={"using":"xpath","value":"//*[@id="elSignIn_submit"]"}
__WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"Failed to decode request as JSON: {\"using\":\"xpath\",\"value\":\"//*[@id=\"elSignIn_submit\"]\"}","stacktrace":"语法错误 at :1:36"}}
_WD_FindElement: {"value":{"error":"invalid argument","message":"Failed to decode request as JSON: {\"using\":\"xpath\",\"value\":\"//*[@id=\"elSignIn_submit\"]\"}","stacktrace":"语法错误 at :1:36"}}
_WD_FindElement ==> Webdriver Exception: HTTP status = 400

 '//*[@id="elSignIn_submit"]' is wrong.....,,but it is obtained through the developer tool:(

Share this post


Link to post
Share on other sites

Hi Dan,

Trying to multi select, using pipe(|) to do an 'and':

$searchForm = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/div/div[@class='related-widget-wrapper']/select[@id='id_groups']/option[@value='1']|/div/div[@class='related-widget-wrapper']/select[@id='id_groups']/option[@value='2']","",True)
 _WD_ElementAction($sSession, $searchForm, 'click')

Gives this output from scite:

__WD_Post: URL=HTTP://127.0.0.1:9515/session/704aa4764b4c7093c86841188c8d1c90/elements; $sData={"using":"xpath","value":"/div/div[@class='related-widget-wrapper']/select[@id='id_groups']/option[@value='1']|/div/div[@class='related-widget-wrapper']/select[@id='id_groups']/option[@value='2']"}
__WD_Post: StatusCode=200; ResponseText={"value":[{"element-6066-11e4-a52e-4f735466cecf":"669755b1-d4d1-4332-9460-f5b9660a912f"},{"element-6066-11e4-a52e-4f735466cecf":"07538cd6-0e65-46c2-abe2-20c53430c9f4"}]}
_WD_FindElement: {"value":[{"element-6066-11e4-a52e-4f735466cecf":"669755b1-d4d1-4332-9460-f5b9660a912f"},{"element-6066-11e4-a52e-4f735466cecf":"07538cd6-0e65-46c2-abe2-20c53430c9f4"}]}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/704aa4764b4c7093c86841188c8d1c90/element//click; $sData={"id":""}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"stale element reference","message":"element is not attached to the page document\n  (Session info: chrome=73.0.3683.103)","stacktrace":"Backtrace:\n\tOrdinal0 [0x011D6170+1597808]\n\tOrdinal0 [0x01132DCD+929229]\n\tOrdinal0 [0x010D6BFF+551935]\n\tOrdinal0 [0x010D87CA+559050]\n\tOrdinal0 [0x010D86B4+558772]\n\tOrdinal0 [0x0106A7D0+108496]\n\tOrdinal0 [0x010660CD+90317]\n\tOrdinal0 [0x0107AD1D+175389]\n\tOrdinal0 [0x01065E68+89704]\n\tOrdinal0 [0x0107AFA1+176033]\n\tOrdinal0 [0x010825CB+206283]\n\tOrdinal0 [0x0107ABBB+175035]\n\tOrdinal0 [0x01063DA0+81312]\n\tOrdinal0 [0x0106535C+86876]\n\tOrdinal0 [0x010652B0+86704]\n\tGetHandleVerifier [0x0128D741+577025]\n\tOrdinal0 [0x011E5573+1660275]\n\tOrdinal0 [0x011E574D+1660749]\n\tOrdinal0 [0x011E599A+1661338]\n\tOrdinal0 [0x011DDEA7+1629863]\n\tOrdinal0 [0x011E53EF+1659887]\n\tOrdinal0 [0x0114870E+1017614]\n\tOrdinal0 [0x0115489B+1067163]\n\tOrdinal0 [0x011549EA+1067498]\n\tOrdinal0 [0x01153A75+1063541]\n\tBaseThreadInitThunk [0x74408764+36]\n\tRtlGetAppContainerNamedObjectPath [0x778C58ED+253]\n\tRtlGetAppContainerNamedObjectPath [0x778C58BD+205]\n"}}
_WD_ElementAction: {"value":{"error":"stale element reference","message":"element is not attached to the page document\...
_WD_ElementAction ==> No match: {"value":{"error":"stale element reference","message":"element is not attached to the page document\n  (Session info: chrome=73.0.3683.103)","stacktrace":"Backtrace:\n\tOrdinal0 [0x011D6170+1597808]\n\tOrdinal0 [0x01132DCD+929229]\n\tOrdinal0 [0x010D6BFF+551935]\n\tOrdinal0 [0x010D87CA+559050]\n\tOrdinal0 [0x010D86B4+558772]\n\tOrdinal0 [0x0106A7D0+108496]\n\tOrdinal0 [0x010660CD+90317]\n\tOrdinal0 [0x0107AD1D+175389]\n\tOrdinal0 [0x01065E68+89704]\n\tOrdinal0 [0x0107AFA1+176033]\n\tOrdinal0 [0x010825CB+206283]\n\tOrdinal0 [0x0107ABBB+175035]\n\tOrdinal0 [0x01063DA0+81312]\n\tOrdinal0 [0x0106535C+86876]\n\tOrdinal0 [0x010652B0+86704]\n\tGetHandleVerifier [0x0128D741+577025]\n\tOrdinal0 [0x011E5573+1660275]\n\tOrdinal0 [0x011E574D+1660749]\n\tOrdinal0 [0x011E599A+1661338]\n\tOrdinal0 [0x011DDEA7+1629863]\n\tOrdinal0 [0x011E53EF+1659887]\n\tOrdinal0 [0x0114870E+1017614]\n\tOrdinal0 [0x0115489B+1067163]\n\tOrdinal0 [0x011549EA+1067498]\n\tOrdinal0 [0x01153A75+1063541]\n\tBaseThreadInitThunk [0x74408764+36]\n\tRtlGetAppContainerNamedObjectPath [0x778C58ED+253]\n\tRtlGetAppContainerNamedObjectPath [0x778C58BD+205]\n"}}

No matter if I put the True statement related to multiselect in _WD_FindElement

Is there a way to multiselect? Like a user does with control key pressed and then selects it with the mouse.

Thanks in advance!

Ansal

Share this post


Link to post
Share on other sites

@Danp2 I tried to get the tagName of a element, but out of success.
 

13.6 Get Element Tag Name
HTTP Method     URI Template
GET     /session/{session id}/element/{element id}/name

my command:

$sValue = _WD_ElementAction($sSession, $sElement, 'name')
     MsgBox(4096, "Webdriver | Function: TestPage: ", "A. pices-type: >" & $sValue &  "<")

message:

__WD_Get: URL=HTTP://127.0.0.1:4444/session/cb79aaa6-a452-41b8-bcfd-11e89655c9b0/element//name
__WD_Get: StatusCode=404; $iResult = 0; $sResponseText={"value":{"error":"unknown command","message":"GET /session/cb79aaa6-a452-41b8-bcfd-11e89655c9b0/ele...
_WD_ElementAction: {"value":{"error":"unknown command","message":"GET /session/cb79aaa6-a452-41b8-bcfd-11e89655c9b0/ele...
_WD_ElementAction ==> Webdriver Exception: {"value":{"error":"unknown command","message":"GET /session/cb79aaa6-a452-41b8-bcfd-11e89655c9b0/element//name did not match a known command","stacktrace":""}}

Where is my mistake ?

Share this post


Link to post
Share on other sites
3 hours ago, ansal said:

_WD_FindElement: {"value":[{"element-6066-11e4-a52e-4f735466cecf":"669755b1-d4d1-4332-9460-f5b9660a912f"},{"element-6066-11e4-a52e-4f735466cecf":"07538cd6-0e65-46c2-abe2-20c53430c9f4"}]}

This shows that the call to _WD_FindElement successfully returned an array of elements. It appears that your issue is that you are then attempting to pass this array to _WD_ElementAction, which isn't valid. You'll need to pass each element you want to click as a parameter on separate calls to _WD_ElementAction if you need to click more than one element.

Share this post


Link to post
Share on other sites
3 hours ago, Hamburgo said:

Where is my mistake ?

Unable to tell without additional details. It could be an issue with the particular version of the Webdriver console you are using. You could try switching to a different browser and testing to see if the issue goes away. If so, then you've isolated it to a particular browser / webdriver version.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   1 member

  • Similar Content

    • By Danp2
      Introduction
      This UDF will allow you to interact with any browser that supports the W3C WebDriver specifications. Supporting multiple browsers via the same code base is now possible with just a few configuration settings.
      Requirements
      JSON UDF https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn
      WinHTTP UDF https://www.autoitscript.com/forum/topic/84133-winhttp-functions/
      WebDriver for desired browser
      Chrome WebDriver https://sites.google.com/a/chromium.org/chromedriver/downloads FireFox WebDriver https://github.com/mozilla/geckodriver/releases Edge WebDriver https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ Function List
      Core Functions
      _WD_CreateSession($sDesiredCapabilities='{}') _WD_DeleteSession($sSession) _WD_Status() _WD_Timeouts($sSession, $sTimeouts = '') _WD_Navigate($sSession, $sURL) _WD_Action($sSession, $sCommand) _WD_Window($sSession, $sCommand, $sOption = '') _WD_FindElement($sSession, $sStrategy, $sSelector, $sStartElement = "", $lMultiple = False) _WD_ElementAction($sSession, $sElement, $sCommand, $sOption='') _WD_ExecuteScript($sSession, $sScript, $sArguments="[]") _WD_Alert($sSession, $sCommand, $sOption = '') _WD_GetSource($sSession) _WD_Cookies($sSession, $sCommand, $sOption = '') _WD_Option($sOption, $vValue = "") _WD_Startup() _WD_Shutdown() Helper Functions
      _WD_NewTab($sSession, $lSwitch = True, $iTimeout = -1, $sURL = "", $sFeatures = "") _WD_Attach($sSession, $sString, $sMode = 'title') _WD_LinkClickByText($sSession, $sText, $lPartial = True) _WD_WaitElement($sSession, $sElement, $sStrategy, $sSelector[, $iDelay = 0[, $iTimeout = -1]]) _WD_GetMouseElement($sSession) _WD_GetElementFromPoint($sSession, $iX, $iY) _WD_LastHTTPResult() _WD_GetFrameCount() _WD_IsWindowTop() _WD_FrameEnter($sIndexOrID) _WD_FrameLeave() _WD_HighlightElements($sSession, $aElements[, $iMethod = 1]) _WD_jQuerify($sSession[, $sjQueryFile = Default[, $iTimeout = Default]]) _WD_ElementOptionSelect($sSession, $sStrategy, $sSelector, $sStartElement = "") _WD_ElementSelectAction($sSession, $sSelectElement, $sCommand) _WD_ConsoleVisible($lVisible = False) _WD_LoadWait($sSession[, $iDelay = 0[, $iTimeout = -1[, $sElement = '']]]) _WD_Screenshot($sSession, $sElement = '', $nOutputType = 1) _WD_SelectFiles($sSession, $sStrategy, $sSelector, $sFilename) _WD_GetShadowRoot($sSession, $sStrategy, $sSelector, $sStartElement = "") _WD_IsLatestRelease() _WD_UpdateDriver($sBrowser[, $sInstallDir = Default[, $lFlag64 = Default[, $lForce = Default]]]) _WD_DownloadFile($sURL, $sDest) Source Code
      You will always be able to find the latest version in the GitHub Repo 
      Help / Support
      Please post any questions, suggestions or errors in the GH&S thread.
      https://www.autoitscript.com/forum/topic/201106-webdriver-udf-help-support-ii/
       
    • By JohnWIlling
      We are running on a VIrtual Machine via Remote Desktop.  We are having a situation where the loading of the chromedriver.exe is taking longer on the VM than on a physical machine.  It is causing the first call to  WD_Post in _WD_CreateSession to fail.
      To workaround the Issue, I used a simplified version of (_WinAPI_GetTcpTable) UDF to Loop waiting for the driver port to be in the listening state.  At that point, I know that the Post will work:
      Func _WaitForPort($ListenPort) Do Local $tMIB_TCPTABLE = DllStructCreate("dword[6]") Local $aRet = DllCall("Iphlpapi.dll", "DWORD", "GetTcpTable", "struct*", $tMIB_TCPTABLE, "DWORD*", 0, "BOOL", True) Local $dwSize = $aRet[2] $tMIB_TCPTABLE = DllStructCreate("DWORD[" & $dwSize / 4 & "]") $aRet = DllCall("Iphlpapi.dll", "DWORD", "GetTcpTable", "struct*", $tMIB_TCPTABLE, "DWORD*", $dwSize, "BOOL", True) If $aRet[0] <> 0 Then Return SetError(1) Local $iNumEntries = DllStructGetData($tMIB_TCPTABLE, 1, 1) Local $aRes[$iNumEntries][6] For $i = 0 To $iNumEntries - 1 Local $Type = DllStructGetData($tMIB_TCPTABLE, 1, 2 + $i * 5 + 0) $aRet = DllCall("ws2_32.dll", "ushort", "ntohs", "uint", DllStructGetData($tMIB_TCPTABLE, 1, 2 + $i * 5 + 2)) ; local port Local $Port = $aRet[0] ConsoleWrite("Checking Row:" & $i & " State:<" & $Type & "> Port:<" & $Port & ">" & @CRLF) ; Type 2 is LISTENING If $Type = 2 And $Port = $ListenPort Then Return 1; EndIF Next Sleep(500); Until 0; Return 0; EndFunc ;==>_WaitForPort  
    • By svenjatzu
      hey hi
      someone please can help me translate my code to be valid for udf webriver?
       
      #RequireAdmin Opt("WinTitleMatchMode",2) ;~ Sleep(10000) ShellExecute("C:\neu\1.lnk") ;~ Sleep(3000) ;~ $PID = ShellExecute("C:\freeneu\tab.exe") ;~ Sleep(30000*5) WinWait("Example Domain - Iron","") Global $sWinTitle = "Example Domain - Iron" Global $avWinList = WinList($sWinTitle) While $avWinList[0][0] < 1 Sleep(250); Wait for new process to create its GUI $avWinList = WinList($sWinTitle) WEnd For $n = 1 To $avWinList[0][0] WinActivate($avWinList[$n][1]) WinMove($avWinList[$n][1], "", 0, 0, 230, 440) Next Opt("WinTitleMatchMode",1) WinWait("Iron") Sleep(5333) WinWait("Iron") Opt("WinTitleMatchMode",2) WinWaitActive("m:") WinWait("m:") WinClose("m:") ;~ Sleep(5000) Sleep(1000) ;~ ProcessClose("tab.exe") ShellExecute(@ScriptDir & "\q2.exe")  
    • By water
      Internet Explorer is nearly dead, newer versions of Firefox can't any longer be automated using Stilgar's FF UDF.
      Hence more and more users (including me) need to look at automating Webbrowsers using WebDriver.
      That's why I have started to create a tutorial in the wiki.
      It should describe all necessary steps from intallation to usage.

      I'm still collecting ideas for the tutorial - that's where you come into play.
      What do you expect to see in such a tutorial?
      Which browsers should be covered (Firefox, Chrome and Edge are settled)? Any questions for the FAQ? Which (high level) coding examples do you expect (like "How to attach to a running browser instance") ... Like to see your comments
       
      ToDo-List:
      Add "Tools" section and add ChroPath plugin. Done. FAQ: "How to attach to a running browser instance". Done. Explain the difference between iuiautomation, iaccessible, autoit, webdriver. Done. The AutoIt FAQ 40 has been extended. Detailed description of each function. Done Example for "how to deal with downloading". Use function _WD_DownloadFile. Example for "how to deal with popups (alerts, print or save dialog). Use function_WD_AlertRespond to respond to a user prompt. Example for "how to deal with multiple tabs". Use functions _WD_NewTab (create a new tab), _WD_Window (close or switch to a tab) and _WD_Attach (attach to existing tab).
    • By water
      The WebDriver UDF provides a toolbox full of functions to facilitate automating Web browsers.
      Still scripts can become quite complex.
      In this thread users can post "real life" examples to show how specific tasks can be implemented.
      Note
      When posting an example please describe the purpose of the script and the WebDriver functionality used!
       
×
×
  • Create New...