Jump to content

Have problems with webdriver (in GH&S)


 Share

Recommended Posts

I've been using AutoIt to automate browser-related things for several years.  Starting this morning, my scripts started failing, and I can't seem to figure it out.  I found a very basic script that experiences the same problem.  It looks like this:

; source from https://www.autoitscript.com/forum/topic/202981-new-to-this-need-help-webdriver-udf-chrome/page/3/

#include "wd_core.au3"
$_WD_DEBUG = $_WD_DEBUG_Info        ; Full logging to console

Local $sDesiredCapabilities, $sSession
SetupChrome()
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)

Func SetupChrome()
    _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')
    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}'
EndFunc

I made sure I have the current chromedriver (chromedriver_win32 (94.0.4606.61)) that and it is in the right directory (C:\Program Files\Google\Chrome\Application), and the Scite console looks like this:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\geoffrey_noakes\Documents\MySystem\Source\MyChromeLib\idea2.au3"    
_WD_Startup: OS:    WIN_10 WIN32_NT 19043 
_WD_Startup: AutoIt:    3.3.14.5
_WD_Startup: WD.au3:    0.4.1.1
_WD_Startup: WinHTTP:    1.6.4.2
_WD_Startup: Driver:    chromedriver.exe
_WD_Startup: Params:    --log-path="C:\Users\geoffrey_noakes\Documents\MySystem\Source\MyChromeLib\chrome.log"
_WD_Startup: Port:    9515
_WD_Startup ==> General Error: Error launching web driver!
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_CreateSession: WinHTTP request timed out before Webdriver
_WD_CreateSession ==> Webdriver Exception: HTTP status = 0
>Exit code: 0    Time: 2.472

I don't know where to start to diagnose and fix this.  Can someone help point out where my problem might be?

Thanks...

Geoff

Link to comment
Share on other sites

3 hours ago, geoffnoakes said:

_WD_Startup: Port:    9515
_WD_Startup ==> General Error: Error launching web driver!

Did you try on few computers ?

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:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

3 hours ago, geoffnoakes said:

I made sure I have the current chromedriver (chromedriver_win32 (94.0.4606.61)) that and it is in the right directory (C:\Program Files\Google\Chrome\Application)

What version of Chrome? Also, what makes that the correct directory? If you are going to place it there, then you likely need to adjust to following line to include the full path --

_WD_Option('Driver', 'chromedriver.exe')

 

Link to comment
Share on other sites

Danp, sorry to take so long -- my daughter's wedding was Saturday.

I am using Chrome "Version 94.0.4606.71 (Official Build) (64-bit)".

I have used the folder "C:\Program Files\Google\Chrome\Application\" for years; I cannot say for sure why, but I think at the time I wanted "all the Chrome stuff to be in one place".  

I made only 1 change to the source (the line with "modified 20211004"):

; source from https://www.autoitscript.com/forum/topic/202981-new-to-this-need-help-webdriver-udf-chrome/page/3/

#include "wd_core.au3"
$_WD_DEBUG = $_WD_DEBUG_Info        ; Full logging to console

Local $sDesiredCapabilities, $sSession
SetupChrome()
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)

Func SetupChrome()
    ; _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('Driver', 'C:\Program Files\Google\Chrome\Application\chromedriver.exe') ; modified 20211004
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')
    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}'
EndFunc

... and the console reports the same problem:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\geoffrey_noakes\Documents\MySystem\Source\MyChromeLib\idea3.au3"    
_WD_Startup: OS:    WIN_10 WIN32_NT 19043 
_WD_Startup: AutoIt:    3.3.14.5
_WD_Startup: WD.au3:    0.4.1.1
_WD_Startup: WinHTTP:    1.6.4.2
_WD_Startup: Driver:    C:\Program Files\Google\Chrome\Application\chromedriver.exe
_WD_Startup: Params:    --log-path="C:\Users\geoffrey_noakes\Documents\MySystem\Source\MyChromeLib\chrome.log"
_WD_Startup: Port:    9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_CreateSession: WinHTTP request timed out before Webdriver
_WD_CreateSession ==> Webdriver Exception: HTTP status = 0
>Exit code: 0    Time: 2.683

Thanks...

Geoff

 

Link to comment
Share on other sites

2 hours ago, geoffnoakes said:

... and the console reports the same problem:

Technically, that statement is inaccurate. It appears that chromedriver was found and launched, but your attempt to create a session failed. Can you post the contents of C:\Users\geoffrey_noakes\Documents\MySystem\Source\MyChromeLib\chrome.log?

I seem to recall reading where recent versions of Chrome / Chromedriver were problematic for some people.

Link to comment
Share on other sites

I ran the same code as before:

; source from https://www.autoitscript.com/forum/topic/202981-new-to-this-need-help-webdriver-udf-chrome/page/3/

#include "wd_core.au3"
$_WD_DEBUG = $_WD_DEBUG_Info        ; Full logging to console

Local $sDesiredCapabilities, $sSession
SetupChrome()
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)

Func SetupChrome()
    ; _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('Driver', 'C:\Program Files\Google\Chrome\Application\chromedriver.exe') ; modified 20211004
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')
    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}'
EndFunc

The console results:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\geoffrey_noakes\Documents\MySystem\Source\MyChromeLib\idea3.au3"    
_WD_Startup: OS:    WIN_10 WIN32_NT 19043 
_WD_Startup: AutoIt:    3.3.14.5
_WD_Startup: WD.au3:    0.4.1.1
_WD_Startup: WinHTTP:    1.6.4.2
_WD_Startup: Driver:    C:\Program Files\Google\Chrome\Application\chromedriver.exe
_WD_Startup: Params:    --log-path="C:\Users\geoffrey_noakes\Documents\MySystem\Source\MyChromeLib\chrome.log"
_WD_Startup: Port:    9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_CreateSession: WinHTTP request timed out before Webdriver
_WD_CreateSession ==> Webdriver Exception: HTTP status = 0
>Exit code: 0    Time: 4.353
 

... and no chrome log file ("chrome.log") was created, either in the directory I would have exepected (@ScriptDir & '\chrome.log"') or anywhere else on my PC (I did a search of "C:" -- no log file at all.

Thanks...

Geoff

Link to comment
Share on other sites

Hmm, some new behavior to report...

I ran the same source (no ,modifications at all.  I turned off Microsoft Defender (the only AV I am using).  The script ran to its end, and the console log reported:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\geoffrey_noakes\Documents\MySystem\Source\MyChromeLib\idea3.au3"    
_WD_Startup: OS:    WIN_10 WIN32_NT 19043 
_WD_Startup: AutoIt:    3.3.14.5
_WD_Startup: WD.au3:    0.4.1.1
_WD_Startup: WinHTTP:    1.6.4.2
_WD_Startup: Driver:    C:\Program Files\Google\Chrome\Application\chromedriver.exe
_WD_Startup: Params:    --log-path="C:\Users\geoffrey_noakes\Documents\MySystem\Source\MyChromeLib\chrome.log"
_WD_Startup: Port:    9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}
__WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"94.0....
_WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"94.0.4606.71","chrome":{"chromedriverVersion":"94.0.4606.61 (418b78f5838ed0b1c69bb4e51ea0252171854915-refs/branch-heads/4606@{#1204})","userDataDir":"C:\\Users\\GEOFFR~1\\AppData\\Local\\Temp\\scoped_dir10392_905620874"},"goog:chromeOptions":{"debuggerAddress":"localhost:51148"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:extension:credBlob":true,"webauthn:extension:largeBlob":true,"webauthn:virtualAuthenticators":true},"sessionId":"30c565ec29d573ee40b1f3b8443191ed"}}
>Exit code: 0    Time: 1.875
 

,,, BUT... a CMD window appeared and did not go away.  I have attached a screenshot of it (could not find a way to scrape it).

Does that help?

Thanks...

Geoff

 

Screenshot-20211006-1030am.png

Link to comment
Share on other sites

7 minutes ago, geoffnoakes said:

Does that help?

Yes, that's the console window for  Chromedriver. There are ways to hide it, but I wouldn't until you've debugged your script.

So the script ran successfully. You will likely need to add an exception to MS Defender so that your script will be able to run with it still enabled. Maybe you can find a log that indicates what was being blocked and why.

Link to comment
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
 Share

  • Recently Browsing   0 members

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