Jump to content

Recommended Posts

Posted

Hello everybody,

thanks for the `great Webdriver UDF and support in this forum.

I am playing around with Webdriver for 2 days now, some things work but other things are not yet clear, would appreciate your support there.
I would like to analyze busy times of some locations on www.google.de/maps. Therefore, i need the visibility of the bar graph for each location (see screenshot below) in order to create a screenshot. Mouse scrolling is not an option for me due to unreliability. I tried to click all available elements in order to make the bar graph visible, but the behaviour changes according to the available information for each location. I found out the best way is to click on the following element with text "06 Uhr" (see 3 in Screenshot):

 image.thumb.png.ad492c6e99cdb2cf58ad1db4523a0a3d.png


Now i found out, that the XPath changes from time to time, so far, i have the following variations.

//*[@id="QA0Szd"]/div/div/div[1]/div[3]/div/div[1]/div/div/div[2]/div[18]/div[3]/div[6]/div[2]/div[3]/div[3]
//*[@id="QA0Szd"]/div/div/div[1]/div[3]/div/div[1]/div/div/div[2]/div[14]/div[3]/div[6]/div[2]/div[3]/div[3]    
//*[@id="QA0Szd"]/div/div/div[1]/div[3]/div/div[1]/div/div/div[2]/div[19]/div[3]/div[6]/div[2]/div[3]/div[3]
//*[@id="QA0Szd"]/div/div/div[1]/div[3]/div/div[1]/div/div/div[2]/div[14]/div[3]/div[7]/div[2]/div[3]/div[3]

First i looped through all variations but it takes much time and i do not know, if there are more variations. Therefore i would like to click XPath by regular expression. Is this possible for XPath?

Or do you an alternative to XPath? I read about 'id', 'class', 'text' but i am not sure how to get the information in Chrome developer tools and also do not know, if it is unique. It seems there are Webdriver funtions to read out these information but how do i point to that element? Don`t i need the XPath at first? 

I found the function _WD_GetElementByRegEx but not sure how to use mode. I guess with XPath it`s not working, right. I could also try "id" or "class", "text" but how to get this information without XPath, please?

If anyone has any other ideas how to create each screenshot reliable, i am also open to other solutions.

Many thanks
tobius

Posted

@tobius

This xpath works for me when testing from within the browser. However, that value for jstcache may not be static so YMMV --

//div[@jstcache='1687']/descendant::div[@jstcache='1267' and not(@aria-hidden='true')]

Actually, it looks like you can drop the first part and just use this

//div[@jstcache='1267' and not(@aria-hidden='true')]

but it still has the same potential issue with jstcache changing.

Posted

@Danp2 Thanks so much for your help, not only for me but in general!
I get an Syntax error with second XPath or am i missing anything:

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//div[@jstcache='1267' and not(@aria-hidden='true')]')



 

Posted

aaaahhh, should switch from ' to " to avoid such mistakes 🙃
Thanks, but unfortunately not working for me, tried both. 
Could you please tell me, how you extracted this XPath? Maybe there is something different in source code, country specification etc.. then i could check, and compare your XPath with mine.

Posted (edited)

Hi I´m new with Webdriver. I want to update all my IE scripts to Firefox.

For _IEFormSubmit I don´t find something simular in WebDriver.
Because submit is not possible I just want to click the button for submission, but I don´t know how. I tried a lot, but nothing works.

Here is the html code for the button

<input type="image" onclick="document.forms[0].command.value='search';document.forms[1].submit();" src="/talos/img/hnwbci/button_suchen.gif">

The image is this: SearchButton.jpg

I found this in the Demo, but I have no name to put it in the code

; Click search button
    $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='btnK']")
    _WD_ElementAction($sSession, $sButton, 'click')
    _WD_LoadWait($sSession, 2000)

Then I tried

_WD_LinkClickByText($sSession,"suchen")

_WD_LinkClickByText($sSession,"Search")

But it also doesn´t work.

Please help, Thanks

Edited by NolleWed
Posted
  On 9/14/2022 at 7:47 AM, NolleWed said:

I found this in the Demo, but I have no name to put it in the code

; Click search button
    $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='btnK']")
    _WD_ElementAction($sSession, $sButton, 'click')
    _WD_LoadWait($sSession, 2000)
Expand  

try:

$sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@src='/talos/img/hnwbci/button_suchen.gif']")

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

it works, thanks 😀

After this I want to get a value, but I always get the false one

HTML Code

<input type="text" name="order.state" value="PORTIERUNG_BESTÄTIGT" readonly="readonly" style="width:180px;" class="bodyCopyDisabled">

AutoIt Code

$FCM_Status_Feld = _WD_FindElement ($sSession, $_WD_LOCATOR_ByXPath,"//input[@name='order.state']")
    _WD_ElementSelectAction($sSession, $FCM_Status_Feld,'VALUE')
    ConsoleWrite("Ergebnis=" & $FCM_Status_Feld & @LF)

Message Console:

_WD_FindElement ==> Success [0] : Parameters:   Strategy=xpath   Selector=//input[@name='order.state']   StartNodeID=Default   Multiple=Default   ShadowRoot=Default
__WD_Get ==> Success [0] : HTTP status = 200
_WD_ElementAction ==> Success [0] : Parameters:   Command=property   Option=nodeName
_WD_ElementSelectAction ==> Invalid argument [5 / 49] : $sCommand = VALUE : Result = 
Ergebnis=498f5d62-0917-4bc2-8b57-46525262af77
 

I want to have the result:

Ergebnis=PORTIERUNG_BESTÄTIGT

 

Did I forgot something?


 

Edited by NolleWed
Posted (edited)

Why you use _WD_ElementSelectAction  on non <select> element ?  
Hint: you should focus on reading function header:

  Quote

; Name ..........: _WD_ElementSelectAction
; Description ...: Perform action on designated <select> element.

Expand  

 

Try this:

Local $sValue = _WD_ElementAction($sSession, $FCM_Status_Feld,'VALUE')
ConsoleWrite("Ergebnis=" & $sValue & @LF)

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)
  On 9/14/2022 at 10:46 AM, NolleWed said:

I look in WebDriver Wiki WebDriver - AutoIt Wiki (autoitscript.com) how to replace _IEFormElementGETValue and here stands that I have to use _WD_ElementSelectAction, thats why I took it.  Sorry I´m a newbie in using WebDriver 

Expand  

Thanks for pointing me to this, I just fixed Wiki page.

  On 9/14/2022 at 10:46 AM, NolleWed said:

With _WD_ElementAction it now works

Expand  

:)

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

I have a new problem. There is another button I wanna click on. But nothing happens.

HTML code:

<input type="submit" value="Änderungen übernehmen" id="saveButton">

I tried with

Local $sButton2 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='Änderungen übernehmen']")
    _WD_ElementAction($sSession, $sButton2, 'click')
    _WD_LoadWait($sSession, 2000)

and get this error in AutoIT:

__WD_Post ==> No match [8] : HTTP status = 404
_WD_FindElement ==> No match [8] : Parameters:   Strategy=xpath   Selector=//input[@name='Änderungen übernehmen']   StartNodeID=Default   Multiple=Default   ShadowRoot=Default
__WD_Post ==> Unknown Command [16] : HTTP status = 405
_WD_ElementAction ==> Unknown Command [16] : Parameters:   Command=click   Option=Default

and this result in WebDriver:

1663569295876   webdriver::server       DEBUG   -> POST /session/77bcff33-d8d6-4ee7-b9ad-7d50e8e3e556/element {"using":"xpath","value":"//input[@name='Änderungen übernehmen']"}
1663569295880   webdriver::server       DEBUG   <- 404 Not Found {"value":{"error":"no such element","message":"Unable to locate element: //input[@name='Änderungen übernehmen']","stacktrace":"WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:181:5\nNoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:393:5\nelement.find/</<@chrome://remote/content/marionette/element.js:305:16\n"}}
1663569297894   webdriver::server       DEBUG   -> POST /session/77bcff33-d8d6-4ee7-b9ad-7d50e8e3e556/execute/sync {"script":"return document.readyState", "args":[]}
1663569297898   webdriver::server       DEBUG   <- 200 OK {"value":"complete"}

 

 

Then I tried with

_WD_LinkClickByText($sSession,"Änderungen übernehmen")
_WD_LoadWait($sSession)

and get this error in AutoIT:

__WD_Post ==> No match [8] : HTTP status = 404
_WD_FindElement ==> No match [8] : Parameters:   Strategy=partial link text   Selector=Änderungen übernehmen   StartNodeID=Default   Multiple=Default   ShadowRoot=Default
_WD_LinkClickByText ==> No match [8] : Parameters:   Text=Änderungen übernehmen   Partial=Default

and this result in WebDriver:

1663568386189   webdriver::server       DEBUG   -> POST /session/df7bbe3d-862e-450f-911b-e7ca76682c93/element {"using":"partial link text","value":"Änderungen übernehmen"}
1663568386217   webdriver::server       DEBUG   <- 404 Not Found {"value":{"error":"no such element","message":"Unable to locate element: Änderungen übernehmen","stacktrace":"WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:181:5\nNoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:393:5\nelement.find/</<@chrome://remote/content/marionette/element.js:305:16\n"}}
1663568386224   webdriver::server       DEBUG   -> POST /session/df7bbe3d-862e-450f-911b-e7ca76682c93/execute/sync {"script":"return document.readyState", "args":[]}
1663568386228   webdriver::server       DEBUG   <- 200 OK {"value":"complete"}

 

How can I find the element and click on it?

Posted

check if there are frames with :  _WD_GetFrameCount()

Also try:

Local $sButton2 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='saveButton']")

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

 

it does not work

__WD_Post ==> Success [0] : HTTP status = 200
_WD_FindElement ==> Success [0] : Parameters:   Strategy=xpath   Selector=//input[@id='saveButton']   StartNodeID=Default   Multiple=Default   ShadowRoot=Default
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ElementAction ==> Success [0] : Parameters:   Command=click   Option=Default
_WD_LoadWait ==> Success [0] : Parameters:    Delay=2000    Timeout=Default    Element=Default
__WD_Post ==> Success [0] : HTTP status = 200

 

1663577466501   webdriver::server       DEBUG   -> POST /session/c273db0f-55d8-4b35-82c1-bf11b70bb6c9/element {"using":"xpath","value":"//input[@id='saveButton']"}
1663577466504   webdriver::server       DEBUG   <- 200 OK {"value":{"element-6066-11e4-a52e-4f735466cecf":"01b2f70c-5861-49f1-a5ff-d2af900f928b"}}
1663577466512   webdriver::server       DEBUG   -> POST /session/c273db0f-55d8-4b35-82c1-bf11b70bb6c9/element/01b2f70c-5861-49f1-a5ff-d2af900f928b/click {"id":"01b2f70c-5861-49f1-a5ff-d2af900f928b"}
1663577467246   webdriver::server       DEBUG   <- 200 OK {"value":null}
1663577469255   webdriver::server       DEBUG   -> POST /session/c273db0f-55d8-4b35-82c1-bf11b70bb6c9/execute/sync {"script":"return document.readyState", "args":[]}
1663577469259   webdriver::server       DEBUG   <- 200 OK {"value":"complete"}

 

Frames:

__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
_WD_GetFrameCount ==> Success [0]

 

In IE I did it with this code

$oIE = _IECreate("https://prodtalos.de.pri.o2.com/talos/fcm/search.do?command=reset",1,1,1,1)

$FCM_FORMULAR_PPC_DETAILS = _IEFormGetObjByName($oIE, "fcmPpcDetailsForm",1)
_IEFormSubmit($FCM_FORMULAR_PPC_DETAILS, "Änderung übernehmen")
_IELoadWait($oIE)

 

Because the script has many forms I search and submit all buttons here in each form for IE with this function:

#include <IE.au3>
_IEFormSubmit(ByRef $o_object [, $f_wait = 1])

$oObject -> Object variable of an InternetExplorer.Application, Form object

 

 Is there simular funtion for WebDriver?

 

All Buttons have the same HTML code, only the value is the difference and the form where the button lies:

<input type="submit" value="XXX">

 

example for a button in form 4:

<input type="submit" value="AKM-TR Weitergeleitet">

 

$FCM_FORMULAR_PPC_DETAILS2 = _IEFormGetObjByName($oIE, "fcmPpcDetailsForm",4)
_IEFormSubmit ($FCM_FORMULAR_PPC_DETAILS2, "AKM-TR Weitergeleitet")
_IELoadWait($oIE)

 

Edited by NolleWed
Posted

I think I found the problem for this Button 

<input type="submit" value="Änderungen übernehmen" id="saveButton">

The button is only enabled, when I change something, but the code for changing a value does not work, thats why the button click does not work. The element was found I think when I check AutoIt and WebDriver console

 

How can I replace the value so that I can test the button click?

$Datum = _ExcelReadCell($oExcelFCMStatus,$indexZeile,3)

$Bestaetigungsdatum_Feld = _WD_FindElement ($sSession, $_WD_LOCATOR_ByXPath,"//input[@name='negotiatedDateString']")
$Bestaetigungsdatum_Wert = _WD_ElementAction($sSession, $Bestaetigungsdatum_Feld,'VALUE')
ConsoleWrite($Bestaetigungsdatum_Wert & @LF)
    
$Bestaetigungsdatum_Feld = _WD_FindElement ($sSession, $_WD_LOCATOR_ByXPath,"//input[@name='negotiatedDateString']")
_WD_SetElementValue($sSession, $Bestaetigungsdatum_Feld, $Datum)

 

field: image.png.c4ec25d3426f39a831143d12ae540123.png

this field has now the value 02.08.2022 and should have the new value 17.08.2022 from Excel

 

__WD_Post ==> Success [0] : HTTP status = 200
_WD_FindElement ==> Success [0] : Parameters:   Strategy=xpath   Selector=//input[@name='negotiatedDateString']   StartNodeID=Default   Multiple=Default   ShadowRoot=Default
__WD_Get ==> Success [0] : HTTP status = 200
_WD_ElementAction ==> Success [0] : Parameters:   Command=VALUE   Option=Default
02.08.2022
__WD_Post ==> Success [0] : HTTP status = 200
_WD_FindElement ==> Success [0] : Parameters:   Strategy=xpath   Selector=//input[@name='negotiatedDateString']   StartNodeID=Default   Multiple=Default   ShadowRoot=Default
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ElementAction ==> Success [0] : Parameters:   Command=value   Option=<masked>
_WD_SetElementValue ==> Success [0] : Parameters:    Element=a612826d-3f70-477d-a0fa-6ffff1884c46    Value=17.08.2022    Style=Default
__WD_Post ==> Success [0] : HTTP status = 200
_WD_FindElement ==> Success [0] : Parameters:   Strategy=xpath   Selector=//input[@id='saveButton']   StartNodeID=Default   Multiple=Default   ShadowRoot=Default
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ElementAction ==> Success [0] : Parameters:   Command=click   Option=Default
_WD_LoadWait ==> Success [0] : Parameters:    Delay=2000    Timeout=Default    Element=Default

 

1663578525466   webdriver::server       DEBUG   -> POST /session/94e85666-ea2e-4df6-a8bb-53e0f9b2f416/element {"using":"xpath","value":"//input[@name='negotiatedDateString']"}
1663578525470   webdriver::server       DEBUG   <- 200 OK {"value":{"element-6066-11e4-a52e-4f735466cecf":"a612826d-3f70-477d-a0fa-6ffff1884c46"}}
1663578525477   webdriver::server       DEBUG   -> GET /session/94e85666-ea2e-4df6-a8bb-53e0f9b2f416/element/a612826d-3f70-477d-a0fa-6ffff1884c46/property/value
1663578525480   webdriver::server       DEBUG   <- 200 OK {"value":"02.08.2022"}
1663578525487   webdriver::server       DEBUG   -> POST /session/94e85666-ea2e-4df6-a8bb-53e0f9b2f416/element {"using":"xpath","value":"//input[@name='negotiatedDateString']"}
1663578525491   webdriver::server       DEBUG   <- 200 OK {"value":{"element-6066-11e4-a52e-4f735466cecf":"a612826d-3f70-477d-a0fa-6ffff1884c46"}}
1663578525498   webdriver::server       DEBUG   -> POST /session/94e85666-ea2e-4df6-a8bb-53e0f9b2f416/element/a612826d-3f70-477d-a0fa-6ffff1884c46/value {"id":"a612826d-3f70-477d-a0fa-6ffff1884c46", "text":"17.08.2022"}
1663578525508   webdriver::server       DEBUG   <- 200 OK {"value":null}
1663578525513   webdriver::server       DEBUG   -> POST /session/94e85666-ea2e-4df6-a8bb-53e0f9b2f416/element {"using":"xpath","value":"//input[@id='saveButton']"}
1663578525515   webdriver::server       DEBUG   <- 200 OK {"value":{"element-6066-11e4-a52e-4f735466cecf":"de3b8f6b-0c02-4615-b64d-7252751ae3e8"}}
1663578525524   webdriver::server       DEBUG   -> POST /session/94e85666-ea2e-4df6-a8bb-53e0f9b2f416/element/de3b8f6b-0c02-4615-b64d-7252751ae3e8/click {"id":"de3b8f6b-0c02-4615-b64d-7252751ae3e8"}
1663578526249   webdriver::server       DEBUG   <- 200 OK {"value":null}
1663578528258   webdriver::server       DEBUG   -> POST /session/94e85666-ea2e-4df6-a8bb-53e0f9b2f416/execute/sync {"script":"return document.readyState", "args":[]}
1663578528262   webdriver::server       DEBUG   <- 200 OK {"value":"complete"}

Posted (edited)

with $_WD_OPTION_Advanced it works and also the click on the button for this HTML code works now

<input type="submit" value="Änderungen übernehmen" id="saveButton">

 

Local $sButton2 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='saveButton']")
Edited by NolleWed
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...