Jump to content

Recommended Posts

Posted
  On 8/30/2021 at 1:27 PM, Danp2 said:

@mLipokIDK. You could try with a different browser. Other thought would be to add some debugging code that performs the click inside a loop until the secondary element is visible.

Expand  

WIP, will share results.

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

Where can I find a working example of automating Chrome browser with autoit? I tried various examples found on this forum but I can't get it to work...

I tested both "chrome_example.auto3" and "chrome_example_2.auto3" from this thread. Of course I made sure to follow the instructions and install the pre-requisites.
From this thread: 

But when I launch the au3 script, it opens the page in the browser then it just hangs there. It doesn't fill any form element or click any link.

I'm afraid I'll get an answer saying "not working" is too vague, but I can't find any information as to why it's not working. It's not writing anything to the console and there is no error message. 

I noticed the examples I used are from 2013 so maybe it's outdated. Is there a more recent version of those 2 examples files ?
I also tested with the most recent example from this page: https://www.autoitscript.com/wiki/WebDriver
I followed the instructions but as soon as I open wd_demo.au3 and click the button to run DemoNavigation in Chrome, it doesn't work. The script opens the browser then instantly closes it.

image.png.3e62816cac02737fb5705c4ae7ca690b.png

 

I also tried using Edge Driver instead, but the browser window instantly closes again

image.png.4d23b13e897e6e2ef9c98143903c390d.png

 

However, if I test with gecko driver (Firefox) then the demo works correctly.

Why isn't it working for Chrome and Edge?

Posted
  On 8/31/2021 at 12:52 AM, ungovernable said:

However, if I test with gecko driver (Firefox) then the demo works correctly.

Why isn't it working for Chrome and Edge?

Expand  

Hard to say without additional details. My guess would be that it can't find the Chrome / Edge executable. To troubleshoot further, please post the results from the Scite output panel after you run wd_demo.

Posted (edited)

I didn't find the solution so I ended up using just the gecko driver. However i'm facing another problem now. I'm not able to click the button, I always get this error:

  Quote

.........................
__WD_Post: URL=HTTP://127.0.0.1:4444/session/129f7eff-da9f-4c1d-b390-f9e765d09c2b/element; $sData={"using":"xpath","value":"//button[@id='onetrust-accept-btn-handler']"}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_FindElement: WinHTTP request timed out before Webdriver
_WD_FindElement ==> Send / Recv error: HTTP status = 0
__WD_Post: URL=HTTP://127.0.0.1:4444/session/129f7eff-da9f-4c1d-b390-f9e765d09c2b/element//click; $sData={"id":""}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_ElementAction: WinHTTP request timed out before Webdriver...
_WD_ElementAction ==> Send / Recv error: WinHTTP request timed out before Webdriver

Expand  

Here's my code:

#include "wd_core.au3"
#include "wd_helper.au3"
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>

Local $sDesiredCapabilities, $iIndex, $sSession
Local $nMsg, $bProcess = False


SetupGecko()
_WD_Startup()
$sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true,"timeouts": {"implicit": 0, "pageLoad": 60000, "script": 30000}}}'
$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://app.spod.com/global")
ConsoleWrite("URL=" & _WD_Action($sSession, 'url') & @CRLF)
_WD_Shutdown()

Func SetupGecko()
_WD_Option('Driver', 'geckodriver.exe')
_WD_Option('DriverParams', '--log trace')
_WD_Option('Port', 4444)
EndFunc


WinWait("Sign-in to your account | SPOD App", "")
Sleep(5000)
ConsoleWrite("........................." & @CRLF)

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@id='onetrust-accept-btn-handler']")
_WD_ElementAction($sSession, $sElement, "click")


exit;

 

Edited by ungovernable
Posted

Sorry here's the full log

  Quote

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "W:\NDNM\SPOD\test firefox.au3"    
_WD_IsLatestRelease: True
_WD_IsLatestRelease ==> Success
_WD_Startup: OS:    WIN_10 WIN32_NT 19043 
_WD_Startup: AutoIt:    3.3.14.5
_WD_Startup: WD.au3:    0.4.1.0 (Up to date)
_WD_Startup: WinHTTP:    1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>)
_WD_Startup: Driver:    geckodriver.exe
_WD_Startup: Params:    --log trace
_WD_Startup: Port:    4444
__WD_Post: URL=HTTP://127.0.0.1:4444/session; $sData={"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true,"timeouts": {"implicit": 0, "pageLoad": 60000, "script": 30000}}}
__WD_Post: StatusCode=200; ResponseText={"value":{"sessionId":"9b22510e-d144-4cab-be92-c185b0ed8da2","capabilities":{"acceptInsecureCerts":t...
_WD_CreateSession: {"value":{"sessionId":"9b22510e-d144-4cab-be92-c185b0ed8da2","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"91.0","javascriptEnabled":true,"moz:accessibilityChecks":false,"moz:buildID":"20210804193234","moz:geckodriverVersion":"0.29.1","moz:headless":false,"moz:processID":23968,"moz:profile":"C:\\Users\\Anarchoi\\AppData\\Local\\Temp\\rust_mozprofilen84tkH","moz:shutdownTimeout":60000,"moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"nativeEvents":true,"pageLoadStrategy":"normal","platformName":"windows","platformVersion":"10.0","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":60000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"}}}
__WD_Post: URL=HTTP://127.0.0.1:4444/session/9b22510e-d144-4cab-be92-c185b0ed8da2/url; $sData={"url":"https://app.spod.com/global"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Navigate: {"value":null}
__WD_Get: URL=HTTP://127.0.0.1:4444/session/9b22510e-d144-4cab-be92-c185b0ed8da2/url
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"https://login.spod.com/"}...
_WD_Action: {"value":"https://login.spod.com/"}
URL=https://login.spod.com/
.........................
__WD_Post: URL=HTTP://127.0.0.1:4444/session/9b22510e-d144-4cab-be92-c185b0ed8da2/element; $sData={"using":"xpath","value":"//button[@id='onetrust-accept-btn-handler']"}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_FindElement: WinHTTP request timed out before Webdriver
_WD_FindElement ==> Send / Recv error: HTTP status = 0
__WD_Post: URL=HTTP://127.0.0.1:4444/session/9b22510e-d144-4cab-be92-c185b0ed8da2/element//click; $sData={"id":""}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_ElementAction: WinHTTP request timed out before Webdriver...
_WD_ElementAction ==> Send / Recv error: WinHTTP request timed out before Webdriver
>Exit code: 0    Time: 14.94
 

Expand  

 

Posted

I just updated WinHttp.au3 but I get the same error

  Quote

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "W:\NDNM\SPOD\test firefox.au3"    
_WD_IsLatestRelease: True
_WD_IsLatestRelease ==> Success
_WD_Startup: OS:    WIN_10 WIN32_NT 19043 
_WD_Startup: AutoIt:    3.3.14.5
_WD_Startup: WD.au3:    0.4.1.0 (Up to date)
_WD_Startup: WinHTTP:    1.6.4.2
_WD_Startup: Driver:    geckodriver.exe
_WD_Startup: Params:    --log trace
_WD_Startup: Port:    4444
__WD_Post: URL=HTTP://127.0.0.1:4444/session; $sData={"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true,"timeouts": {"implicit": 0, "pageLoad": 60000, "script": 30000}}}
__WD_Post: StatusCode=200; ResponseText={"value":{"sessionId":"ca8f2c59-8e10-43e6-9de3-dbff66aad230","capabilities":{"acceptInsecureCerts":t...
_WD_CreateSession: {"value":{"sessionId":"ca8f2c59-8e10-43e6-9de3-dbff66aad230","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"91.0","javascriptEnabled":true,"moz:accessibilityChecks":false,"moz:buildID":"20210804193234","moz:geckodriverVersion":"0.29.1","moz:headless":false,"moz:processID":33860,"moz:profile":"C:\\Users\\Anarchoi\\AppData\\Local\\Temp\\rust_mozprofileHHGozM","moz:shutdownTimeout":60000,"moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"nativeEvents":true,"pageLoadStrategy":"normal","platformName":"windows","platformVersion":"10.0","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":60000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"}}}
__WD_Post: URL=HTTP://127.0.0.1:4444/session/ca8f2c59-8e10-43e6-9de3-dbff66aad230/url; $sData={"url":"https://app.spod.com/global"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Navigate: {"value":null}
__WD_Get: URL=HTTP://127.0.0.1:4444/session/ca8f2c59-8e10-43e6-9de3-dbff66aad230/url
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"https://login.spod.com/"}...
_WD_Action: {"value":"https://login.spod.com/"}
URL=https://login.spod.com/
.........................
__WD_Post: URL=HTTP://127.0.0.1:4444/session/ca8f2c59-8e10-43e6-9de3-dbff66aad230/element; $sData={"using":"xpath","value":"//button[@id='onetrust-accept-btn-handler']"}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_FindElement: WinHTTP request timed out before Webdriver
_WD_FindElement ==> Send / Recv error: HTTP status = 0
__WD_Post: URL=HTTP://127.0.0.1:4444/session/ca8f2c59-8e10-43e6-9de3-dbff66aad230/element//click; $sData={"id":""}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_ElementAction: WinHTTP request timed out before Webdriver...
_WD_ElementAction ==> Send / Recv error: WinHTTP request timed out before Webdriver
>Exit code: 0    Time: 15.59
 

Expand  

Thanks for the fast answers 👍

Posted
  On 8/31/2021 at 2:28 AM, ungovernable said:

$sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true,"timeouts": {"implicit": 0, "pageLoad": 60000, "script": 30000}}}'

Expand  

Have you tried it without the modified timeouts? Something like --

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}'

 

Posted

Yes I tried without the timeouts, I added it because I googled the error and it was suggested in another thread to add timeouts to $sDesiredCapabilities

Just reverted it back to the code you posted and I got the same error

  • Danp2 changed the title to WebDriver UDF (W3C compliant version) - 08/31/2021
Posted

Latest update just released. See below for change log.

  Quote

    v0.4.1.1
    - Fix (_WD_NewTab): Properly detect $sCurrentTabHandle retrieval
    - Changed (_WD_UpdateDriver): Improve error handling (seadoggie01)
    - Added: __WD_Sleep
        - Changed (_WD_Option): Added support for "Sleep" option
        - Chore: Use __WD_Sleep instead of Sleep in "helper" functions
    - Chore: Updated wd_demo.au3
        - Call correct Base64 decode function
        - Remove "binary" portion of MS Edge Capabilities string
    - Chore: Add remark to _WD_GetSession

Expand  

 

Posted

@Danp2


Big thanks for adding this feature that we talked about earlier - I mean   __WD_Sleep().
Unfortunately, I didn't have time to do it myself.

I will do my tests and post my DEMO script in next few days.

btw.
In change log for v0.4.1.1
Please  consider to add remark about: $_WD_ERROR_UserAbort
 

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 another question... What's wrong with my XPath?

$spod_image_size_element = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//g[@class='configuration-info']/text")
        $spod_image_size = _WD_ElementAction($sSession, $spod_image_size_element, 'property', 'value')

image.png.c448df3eed625253d83d56651cfac517.png

here's the element in dev console:

image.thumb.png.a0f4cf15fe38944f57cbff2d962614d0.png

 

the <text> element shows up dynamically, it appears only when I hold the mouse button over the image to resize it. So I try to catch it in a loop:

while 1
        sleep(5000)
        $spod_image_size_element = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//g[@class='configuration-info']")
        $spod_image_size = _WD_ElementAction($sSession, $spod_image_size_element, 'property', 'value')
            msgbox(0,"Element text = " & $spod_image_size, "")
WEnd

 

I also tried to get the parent element instead (g.configuration-info) but still can't be found:

image.png.e42a3c5402aef9aced13dfa56e758864.png

this doesn't work either:

//g[contains(@class, 'configuration-info')]

 

Posted
  On 9/1/2021 at 3:30 AM, ungovernable said:

Is there a way to save cookies with WebDriver so I don't have to re-login every time I restart my script?

Expand  

Unless you instruct otherwise, a new temporary user profile is used each time you launch the browser with webdriver. I haven't needed to save / restore cookies, so I don't really have advice in this area other than to point you to the _WD_Cookies function.

  On 9/1/2021 at 8:20 AM, ungovernable said:

What's wrong with my XPath?

Expand  

Have you checked to see if the page uses frames?

Posted

For those interested - please have a look here:

 

 

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

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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