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
Posted (edited)
_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

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

  • 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 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_HighlightElement($sSession, $sElement[, $iMethod = 1]) _WD_HighlightElements($sSession, $aElements[, $iMethod = 1]) _WD_jQuerify($sSession) WD_ElementOptionSelect($sSession, $sStrategy, $sSelector, $sStartElement = "") _WD_ConsoleVisible($lVisible = False) 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/192730-webdriver-udf-help-support/
    • By Davidowicza
      Hey guys,
      I am creating my very first script that automates a browser (I usually work with program installs and database automation) and have come across an issue that I am totally stumped on. I need to click an element that gives me a drop down list box but the Xpath to the element changes with every instance of chrome I start...
      I have tried selecting the class, rect, and path but no luck. It never finds the element. (I could be doing this wrong since I am not good at HTML)
      Element I need to select:
      This is the Xpath for the last 3 instances of chrome I have run the script with:
      //*[@id="highcharts-5bp9crq-8"]/svg/g[6]/g/rect //*[@id="highcharts-fiw9szv-8"]/svg/g[6]/g/rect //*[@id="highcharts-5szkmx8-8"]/svg/g[6]/g/rect As you can see the path changes every time.
      How I am trying to select the element:
      ;Check for box element _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='highcharts-5bp9crq-8']/svg/g[6]/g") MsgBox(0, "", "check for timeout") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='highcharts-5bp9crq-8']/svg/g[6]/g") _WD_ElementAction($sSession, $sElement, 'click') Maybe someone has come across this before and found a work around without using mouseclick()
      Thanks guys, hopefully I am just very overlooking something simple and can be pointed to the right solution.
      Side Note: I wish I could share the webpage entirety, but it has sensitive information with my agency that I cannot share. If you need more, just let me know and I will try and post as much as I can.
    • By daluu
      This is kind of already posted here:
      '?do=embed' frameborder='0' data-embedContent>>
      but wanted to note this in this forum of example scripts in case some people only look in this forum for examples and not the other forums with respect to AutoIt integration or relation to Selenium WebDriver.
      So, the example in summary is: you can use Selenium WebDriver API to do AutoIt GUI automation (the ControlXyz() and WinXyz() functons, along with mouse and "send keys" functions). Although I suppose that might be opposite or counter to what most examples here are about - using AutoIt to do or control other stuff rather than using other stuff to control/run AutoIt. But regardless, it is an example implementation of a different use case for AutoIt beyond the general AutoIt community, like those who also use Selenium WebDriver and/or need to integrate Selenium with AutoIt for remote deployment.
      https://github.com/daluu/AutoItDriverServer
      with specific demo examples here:
      https://github.com/daluu/AutoItDriverServer/blob/master/sample-code/CalculatorTest.java
      https://github.com/daluu/AutoItDriverServer/blob/master/sample-code/calculator.py
      https://github.com/daluu/AutoItDriverServer/blob/master/sample-code/SeleniumIntegrationTest.java
      https://github.com/daluu/AutoItDriverServer/blob/master/sample-code/SeleniumIntegrationWithAutoItDriver.py
×
×
  • Create New...