Jump to content

WebDriver UDF (W3C compliant version) - 2024/09/21


Danp2
 Share

Recommended Posts

elucidation  about use webdriver  , hi is my first time i  try to use webdriver , i install all (by wiki ) i test my installation and return all ok

_WD_IsLatestRelease: True
_WD_IsLatestRelease ==> Success
_WDStartup: OS: WIN_10 WIN32_NT 18363 
_WDStartup: AutoIt: 3.3.14.5
_WDStartup: WD.au3: 0.3.0.8 (Up to date)
_WDStartup: WinHTTP:    1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>)
_WDStartup: Driver: geckodriver.exe
_WDStartup: Params: --log trace
_WDStartup: Port:   4444
__WD_Post: URL=HTTP://127.0.0.1:4444/session; $sData={"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}
__WD_Post: StatusCode=200; ResponseText={"value":{"sessionId":"700e6df9-5872-4cdc-b76c-15e7447335c7","capabilities":{"acceptInsecureCerts":t...
_WD_CreateSession: {"value":{"sessionId":"700e6df9-5872-4cdc-b76c-15e7447335c7","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"80.0.1","moz:accessibilityChecks":false,"moz:buildID":"20200831163820","moz:geckodriverVersion":"0.27.0","moz:headless":false,"moz:processID":9028,"moz:profile":"C:\\Users\\pc\\AppData\\Local\\Temp\\rust_mozprofileRb5Kzi","moz:shutdownTimeout":60000,"moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"pageLoadStrategy":"normal","platformName":"windows","platformVersion":"10.0","rotatable":false,"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"}}}
Bypass: DemoTimeouts
+Running: DemoNavigation
__WD_Post: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/url; $sData={"url":"http://google.com"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Navigate: {"value":null}
__WD_Get: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/window/handles
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":["18"]}...
_WD_Window: {"value":["18"]}...
__WD_Get: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/window
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"18"}...
_WD_Window: {"value":"18"}...
__WD_Post: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/execute/sync; $sData={"script":"window.open(arguments[0], '', arguments[1])", "args":["",""]}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_ExecuteScript: {"value":null}...
__WD_Get: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/window/handles
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":["18","4294967299"]}...
_WD_Window: {"value":["18","4294967299"]}...
__WD_Post: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/window; $sData={"handle":"4294967299"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Window: {"value":null}...
__WD_Post: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/url; $sData={"url":"http://yahoo.com"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Navigate: {"value":null}
__WD_Get: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/window/handles
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":["18","4294967299"]}...
_WD_Window: {"value":["18","4294967299"]}...
__WD_Get: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/window
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"4294967299"}...
_WD_Window: {"value":"4294967299"}...
__WD_Post: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/execute/sync; $sData={"script":"window.open(arguments[0], '', arguments[1])", "args":["http://bing.com","width=200,height=200"]}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_ExecuteScript: {"value":null}...
__WD_Get: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/window/handles
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":["18","4294967299","4294967300"]}...
_WD_Window: {"value":["18","4294967299","4294967300"]}...
__WD_Post: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/window; $sData={"handle":"4294967300"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Window: {"value":null}...
__WD_Get: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/url
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"about:blank"}...
_WD_Action: {"value":"about:blank"}
URL=about:blank
__WD_Get: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/window/handles
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":["18","4294967299","4294967300"]}...
_WD_Window: {"value":["18","4294967299","4294967300"]}...
__WD_Get: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/window
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"4294967300"}...
_WD_Window: {"value":"4294967300"}...
__WD_Post: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/window; $sData={"handle":"18"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Window: {"value":null}...
__WD_Get: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/url
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"https://www.google.com/?gws_rd=ssl"}...
_WD_Action: {"value":"https://www.google.com/?gws_rd=ssl"}
__WD_Get: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/url
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"https://www.google.com/?gws_rd=ssl"}...
_WD_Action: {"value":"https://www.google.com/?gws_rd=ssl"}
URL=https://www.google.com/?gws_rd=ssl
__WD_Get: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/window/handles
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":["18","4294967299","4294967300"]}...
_WD_Window: {"value":["18","4294967299","4294967300"]}...
__WD_Get: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/window
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"18"}...
_WD_Window: {"value":"18"}...
__WD_Post: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/window; $sData={"handle":"18"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Window: {"value":null}...
__WD_Get: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/url
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"https://www.google.com/?gws_rd=ssl"}...
_WD_Action: {"value":"https://www.google.com/?gws_rd=ssl"}
__WD_Post: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/window; $sData={"handle":"4294967299"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Window: {"value":null}...
__WD_Get: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/url
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"https://consent.yahoo.com/v2/collectConsent?sessionId=3_cc-session_6656d9e3-6f2c-4c72-9ebb...
_WD_Action: {"value":"https://consent.yahoo.com/v2/collectConsent?sessionId=3_cc-session_6656d9e3-6f2c-4c72-9ebb-ce8a591878f0"}
__WD_Get: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7/url
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"https://consent.yahoo.com/v2/collectConsent?sessionId=3_cc-session_6656d9e3-6f2c-4c72-9ebb...
_WD_Action: {"value":"https://consent.yahoo.com/v2/collectConsent?sessionId=3_cc-session_6656d9e3-6f2c-4c72-9ebb-ce8a591878f0"}
URL=https://consent.yahoo.com/v2/collectConsent?sessionId=3_cc-session_6656d9e3-6f2c-4c72-9ebb-ce8a591878f0
+Finished: DemoNavigation
Bypass: DemoElements
Bypass: DemoScript
Bypass: DemoCookies
Bypass: DemoAlerts
Bypass: DemoFrames
Bypass: DemoActions
Bypass: DemoDownload
Bypass: DemoWindows
Bypass: DemoUpload
__WD_Delete: URL=HTTP://127.0.0.1:4444/session/700e6df9-5872-4cdc-b76c-15e7447335c7
__WD_Delete: StatusCode=200; ResponseText={"value":null}...
_WD_DeleteSession: {"value":null}

but now i try to  create a script  i write  this code  but tell me  

_WD_Startup ==> Invalid value: Location for Web Driver not set.

 

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.5
 Author:         faustf

 Script Function:
    lillirobot

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
; Script Start - Add your code below here
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <Array.au3>
#include "wd_core.au3"
#include "wd_helper.au3"
#include <GuiComboBoxEx.au3>


Global $sDesiredCapabilities,$sSession




_WD_Startup()

If @error <> $_WD_ERROR_Success Then
    Exit -1
EndIf

$sSession = _WD_CreateSession($sDesiredCapabilities)

_WD_Navigate($sSession, "https://www.instagram.com/?hl=it")



_WD_DeleteSession($sSession)
_WD_Shutdown()

whats wrong _ thankz at all

Edited by faustf
Link to comment
Share on other sites

12 minutes ago, faustf said:

_WDStartup: WinHTTP:    1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>)

Please follow the provided link and update your source for WinHttp.au3

13 minutes ago, faustf said:

_WD_Startup ==> Invalid value: Location for Web Driver not set.

You haven't told it which web driver to use. If you check out wd_demo again, you'll see "setup" functions for Chrome, Firefox and Edge. Each one uses _WD_Option to supply some basic configuration settings so that the UDF can find the executable, knows the correct port to use, etc. This is also where the "capabilities" string gets defined so that it can be used later on during session creation.

Link to comment
Share on other sites

@faustf Because that isn't how I designed it. 😉

Plus, everyone has different setups, so any "default" settings would likely need to be changed by the script writer to work in their environment. So you need to handle this in each script that you write, or you can create your own "include" file that contains your default setup and use that in each script you write.

Link to comment
Share on other sites

Quote

Sorry, but I don't understand your explanation of the problem. If you are supplying a profile in the Capacities string, then I don't understand how the wrong profile could be loading. Is this all occurring in instances launched via geckodriver

I already set the intended profile in Capacities string & it does work properly. However, this is only when this session is current and the only existing instance of firefox like I mentioned.

When a second firefox instance is opened, running coherently and this one is closed first before the first; it'll become the new instance geckodriver opens the next time it is run.

Quote

are you manually launching firefox in some instance.

Nope, I'm strictly running wd_demo straight from AutoIt's SciTe with F5.

edit:
Okay, got it working. It seems that windows kept asking to close firefox like it was re-opening the same instance. Even after it was closed. Running the script was just re-opening the closed firefox instance (whichever one didn't matter it seems)

Edited by Purity8
Solved
Link to comment
Share on other sites

I installed how described in the wiki  https://www.autoitscript.com/wiki/WebDriver , with Chrome webdriver

Then I started the demo wd_demo.au3 , selected Chrome / DemoNavigation / Full / Run Demo!

It more or less worked, but there were strange things.

Bing did not open in a tab, but in a separate small window.

There was an error in the console related to bluetooth (but I think my PC has no bluetooth adapter, which might explain it).

I took a screenshot of the result: I moved windows around, but did not resize anything.

Am I on the right track?

ScreenshotWebDriver.jpg

Link to comment
Share on other sites

Ok, next step.
I succeeded in running the demo on Firefox.
I downloaded into the same directory, and run the demo "GDPR fines.au3", but I get an error because the function _WD_GetTable is defined both in this file and in wd_helper.au3.
If I comment out the definition in wd_helper all works. But, does it mean that there was some version mismatch?

Link to comment
Share on other sites

I updated to the latest version yesterday & started getting this message in console while downloading files. It occurs randomly at any moment.

"C:\Users\Admin\Documents\Scripts\AutoIt\Required\wd_core.au3" (1527) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$sMsg = $sWhere & " ==> " & $aWD_ERROR_DESC[$i_WD_ERROR]
$sMsg = $sWhere & " ==> " & ^ ERROR

I've never had problems with the previous version.

Link to comment
Share on other sites

v0.3.0.9 has been released with the following updates --

  •     Changed (_WD_GetTable): Filter html elements by default when using _HtmlTableGetWriteToArray
  •     Fix (_WD_DownloadFile): Handle error from InetRead
  •     Changed (_WD_DownloadFile): Add $iOptions parameter
  •     Chore: Updated wd_demo.au3
    •         Update binary location of Edge browser
    •         Update DemoDownload example
    •         Misc updates

 

Link to comment
Share on other sites

I noticed error code 13 has now become error code 4. This typically happens when a gallery ends & there's a 404 message saying file not found; which is normal.

Not really a problem, but I'll need to make minor adjustments in some functions.

Edited by Purity8
Link to comment
Share on other sites

  • Danp2 changed the title to WebDriver UDF (W3C compliant version) - 2024/09/21
  • Melba23 pinned this topic

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
 Share

×
×
  • Create New...