Jump to content

Difficulties starting the Chrome Webdriver, Webdriver Exception [10]


_leo_
 Share

Recommended Posts

My script has been working without issues for multiple years, but lately, without changing the code, I have been having some problems with starting the chrome web driver. I updated all the drivers and imports and switched to using "CapabilitiesAdd", but I still get a "Webdriver Exception [10]. "WinHTTP request timed out before Webdriver" appears in the output, but I updated the UDF to the latest release.

For context: I am able to run wd_demo without this problem, but when I try to add capabilities to the demo, like a chrome profile, the code produces a "DevToolsActivePort file doesn't exist" error, which I tried to solve with the commented out capabilities, but I had no success.

Here is my code:

#include <FileConstants.au3>
#include <StringConstants.au3>
#include "wd_core.au3"
#include "wd_helper.au3"
#include <String.au3>
#include "wd_capabilities.au3"

HotKeySet("{Esc}", "ExitScript")
Func ExitScript()
Exit
EndFunc
Global $sSession
$_WD_DEBUG = $_WD_DEBUG_Full
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')

;$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"unhandledPromptBehavior": "ignore", ' & _{"goog:chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars", "disable-notifications", "--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
_WD_CapabilitiesStartup()
_WD_CapabilitiesAdd('alwaysMatch', 'chrome')
_WD_CapabilitiesAdd('w3c', True)
_WD_CapabilitiesAdd('excludeSwitches', 'enable-automation')
;_WD_CapabilitiesAdd('args', '--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\')    
;_WD_CapabilitiesAdd('args', 'profile-directory=Default')
;_WD_CapabilitiesAdd('args', 'start-maximized')
;_WD_CapabilitiesAdd('args', 'disable-infobars')
;_WD_CapabilitiesAdd('args', 'disable-notifications')    
;_WD_CapabilitiesAdd('args', '--disable-blink-features=AutomationControlled')
;_WD_CapabilitiesAdd('args', '--disable-web-security')
;_WD_CapabilitiesAdd('args', '--allow-running-insecure-content')
;_WD_CapabilitiesAdd('args', '--ignore-certificate-errors')
;_WD_CapabilitiesAdd('prefs', 'credentials_enable_service', False)
;_WD_CapabilitiesAdd('excludeSwitches', 'disable-popup-blocking')
Local $sCapabilities = _WD_CapabilitiesGet()
$sSession = _WD_CreateSession($sCapabilities)
_WD_CheckContext($sSession, False)
_WD_Startup()
If @error <> $_WD_ERROR_Success Then
    Exit -1
EndIf
Sleep(10000)
_WD_Shutdown()


And this is the output:

_WD_Option ==> Success [0] : Parameters:   Option=Driver   Value=chromedriver.exe
_WD_Option ==> Success [0] : Parameters:   Option=Port   Value=9515
_WD_Option ==> Success [0] : Parameters:   Option=DriverParams   Value=--verbose --log-path="C:\Users\leona\OneDrive\Desktop\chrome.log"
_WD_CapabilitiesStartup: #148 : > {"capabilities":"{}"} > IsObj = 1
_WD_CapabilitiesAdd: #177 :      $key = alwaysMatch     $value1 = chrome     $value2 = 
_WD_CapabilitiesAdd: #205 :  $_WD_NOTATION__MATCHTYPE = [capabilities][alwaysMatch] $_WD_NOTATION__SPECIFICVENDOR = ["goog:chromeOptions"]
_WD_CapabilitiesAdd ==> Success [0] : Successfully used [alwaysMatch]  with specified browser: chrome
_WD_CapabilitiesAdd: #177 :      $key = w3c     $value1 = True     $value2 = 
_WD_CapabilitiesAdd: #259 #275 :      $key = w3c     $value1 = True     $value2 =     $s_Notation = [capabilities][alwaysMatch]["goog:chromeOptions"]["w3c"]   <<<<  True
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd: #177 :      $key = excludeSwitches     $value1 = enable-automation     $value2 = 
_WD_CapabilitiesAdd: #239 #275 :      $key = excludeSwitches     $value1 = enable-automation     $value2 =     $s_Notation = [capabilities][alwaysMatch]["goog:chromeOptions"]["excludeSwitches"][0]   <<<<  enable-automation
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
__WD_Post: URL=HTTP://127.0.0.1:9515/session; Data={
    "capabilities":{
        "alwaysMatch":{
            "goog:chromeOptions":{
                "w3c":true,
                "excludeSwitches":[
                    "enable-automation"
                ]
            }
        }
    }
}
__WD_Post ==> Send / Recv error [6] : HTTP status = 0 ResponseText=WinHTTP request timed out before Webdriver
_WD_CreateSession ==> Webdriver Exception [10]
__WD_Get: URL=HTTP://127.0.0.1:9515/session//url
__WD_Get ==> Send / Recv error [6] : HTTP status = 0 ResponseText=WinHTTP request timed out before Webdriver
_WD_Action ==> Send / Recv error [6] : Parameters:   Command=url   Option=Default
_WD_CheckContext ==> Webdriver Exception [10]
_WD_GetFreePort ==> Success [0 / 9515] : Parameters:   MinPort=9515   MaxPort=Default
_WD_IsLatestRelease ==> Success [0] : True
_WD_Startup: OS:    WIN_11 X64 22621 
_WD_Startup: AutoIt:    3.3.16.1
_WD_Startup: Webdriver UDF:    1.2.0 (Up to date)
_WD_Startup: WinHTTP:    1.6.4.2
_WD_Startup: Driver:    chromedriver.exe (64 Bit)
_WD_Startup: Params:    --verbose --log-path="C:\Users\leona\OneDrive\Desktop\chrome.log"
_WD_Startup: Port:    9515
_WD_Startup: Command:    "chromedriver.exe" --verbose --log-path="C:\Users\leona\OneDrive\Desktop\chrome.log" 
_WD_Startup ==> Success [0]

 

Link to comment
Share on other sites

@Danp2 Thank you very much for your help. That fixed the Webdriver Exception [10].

When I now try to add a Chrome profile by uncommenting the lines:

_WD_CapabilitiesAdd('args', '--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\')    
_WD_CapabilitiesAdd('args', 'profile-directory=Default')

I get a "DevToolsActivePort file doesn't exist" error (the Chrome profile is loaded). In previous discussions, I saw that some capabilities might help to resolve this, but none of these helped:

_WD_CapabilitiesAdd('args', '--disable-blink-features=AutomationControlled')
_WD_CapabilitiesAdd('args', '--disable-web-security')
_WD_CapabilitiesAdd('args', '--allow-running-insecure-content')
_WD_CapabilitiesAdd('args', '--ignore-certificate-errors')
_WD_CapabilitiesAdd('prefs', 'credentials_enable_service', False)
_WD_CapabilitiesAdd('excludeSwitches', 'disable-popup-blocking')

I tried them one by one and in combination. Thanks in advance for your help!

Link to comment
Share on other sites

@Danp2 Thank you for your input! I changed the code to your suggestion, but the console output still looks the same.

I also experimented with some other syntaxes:

_WD_CapabilitiesAdd('args', '--profile-directory', Default)
_WD_CapabilitiesAdd('args', '--profile-directory', "Default")
_WD_CapabilitiesAdd('args', 'profile-directory', Default)
_WD_CapabilitiesAdd('args', 'profile-directory', "Default")

No matter which syntax, the Chrome driver behaves the same way, even if I don't add a profile directory, which might indicate that none of the syntaxes are correct. 

I also experimented with the user data directory. I found, that both syntaxes made Chrome load the profile, but also both produced the DevToolsActivePort error. Hence, not specifying the user data, prevents the error but also doesn't load the profile.

_WD_CapabilitiesAdd('args', '--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\')
_WD_CapabilitiesAdd('args', '--user-data-dir', 'C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\')

The console output:

__WD_Post ==> Session not created [15] : HTTP status = 500
_WD_CreateSession ==> Session not created [15] : session not created: Chrome failed to start: exited normally.
  (session not created: DevToolsActivePort file doesn't exist)
  (The process started from chrome location C:\Program Files\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

 

Link to comment
Share on other sites

2 hours ago, Danp2 said:

Are you launching your script in elevated mode? That could explain the issue as the Admin user wouldn't have rights to the files in the profile directory.

Not sure what exactly you mean.
I have some experience in runing WD with elevated AutoIt script so I checked how Chrome/FireFox runs as Admin.

I notice is that they probably use the same profile in elevated an non elevated mode, as when I run as Admin then I get the same pined links in "bookmarks bar/panel".

Please verify if my reasoning is correct.
 

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

I tried to run the script with #RequireAdmin, if that is what you meant, but it had no impact. 

I also found a topic on stack overflow: https://stackoverflow.com/questions/50642308/webdriverexception-unknown-error-devtoolsactiveport-file-doesnt-exist-while-t, about the same issue with selenium. My updated capabilities look like this: 

_WD_CapabilitiesAdd('args', '--no-sandbox')
_WD_CapabilitiesAdd('alwaysMatch', 'chrome')
_WD_CapabilitiesAdd('w3c', True)
;_WD_CapabilitiesAdd('args', '--remote-debugging-port=9222') --> Results in Error: "Chrome not reachable", so commented out
_WD_CapabilitiesAdd('excludeSwitches', 'enable-automation')
_WD_CapabilitiesAdd('args', 'start-maximized')
_WD_CapabilitiesAdd('args', '--disable-dev-shm-usage')
_WD_CapabilitiesAdd('args', '--disable-gpu')
_WD_CapabilitiesAdd('args', 'disable-infobars')
_WD_CapabilitiesAdd('args', '--crash-dumps-dir=/tmp')
_WD_CapabilitiesAdd('args', 'disable-notifications')    
_WD_CapabilitiesAdd('args', '--disable-blink-features=AutomationControlled')
_WD_CapabilitiesAdd('args', '--disable-web-security')
_WD_CapabilitiesAdd('args', '--allow-running-insecure-content')
_WD_CapabilitiesAdd('args', '--ignore-certificate-errors')
_WD_CapabilitiesAdd('prefs', 'credentials_enable_servisce', False)
_WD_CapabilitiesAdd('excludeSwitches', 'disable-popup-blocking') 
_WD_CapabilitiesAdd('args', '--user-data-dir', 'C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\')
_WD_CapabilitiesAdd('args', '--profile-directory', Default)

I am not sure if that made it better or worse. The error still exists.

Link to comment
Share on other sites

5 hours ago, _leo_ said:
_WD_CapabilitiesAdd('args', '--crash-dumps-dir=/tmp')

is this relationall to which folder ?

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

5 hours ago, _leo_ said:
_WD_CapabilitiesAdd('args', '--user-data-dir', 'C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\')

why you use duplicated back slashes ?
I use:

Func _MY__WD_ProfileDir($s_Browser_Name)
    Switch $s_Browser_Name
        Case "chrome"
            Return @LocalAppDataDir & '\Google\Chrome\User Data\WD_Testing_Profile'
        Case "firefox"
            Return @LocalAppDataDir & '\Mozilla\Firefox\Profiles\WD_Testing_Profile'
        Case "msedge"
            Return @LocalAppDataDir & '\Microsoft\Edge\User Data\WD_Testing_Profile'
        Case Else
            Return SetError($_WD_ERROR_NotSupported, @extended, '')
    EndSwitch
EndFunc   ;==>_MY__WD_ProfileDir

 

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

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...