YGYL0 Posted 2 hours ago Share Posted 2 hours ago #include "wd_helper.au3" #include "wd_capabilities.au3" $bHeadless = False $sCapabilities = SetupChrome($bHeadless) If @error Then MsgBox(0, @error, @extended) Local $iWebDriver_PID = _WD_Startup() $sSession = _WD_CreateSession($sCapabilities) _WD_Navigate($sSession, 'https://www.baidu.com') _WD_LoadWait($sSession) MsgBox(0,"","OK") Func SetupChrome($bHeadless) _WD_Option('Driver', 'chromedriver.exe') Local $iPort = _WD_GetFreePort(5555, 5600) ;~ If @error Then Return SetError(@error, @extended, 0) _WD_Option('Port', $iPort) _WD_Option('DriverParams', '--port=' & $iPort & ' --verbose --log-path="' & @ScriptDir & '\chrome.log"') ;~ Local $sCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"]}}}}' _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch', 'chrome') _WD_CapabilitiesAdd('w3c', True) _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation') If $bHeadless Then _WD_CapabilitiesAdd('args', '--headless') _WD_CapabilitiesDump(@ScriptLineNumber) ; dump current Capabilities setting to console - only for testing in this demo Local $sCapabilities = _WD_CapabilitiesGet() Return $sCapabilities EndFunc ;==>SetupChrome Google Chrome 131.0.6778.70 chromedriver 131.0.6778.69 au3WebDriver-1.4.0 Google Chrome for Testing 131.0.6778.69 ,install dir is d:\gct131\chrome.exe The format of "binary=". And Testing port? Link to comment Share on other sites More sharing options...
Danp2 Posted 1 hour ago Share Posted 1 hour ago There's a FAQ in the wiki for specifying the location of the browser executable -- https://www.autoitscript.com/wiki/WebDriver#FAQ Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
YGYL0 Posted 10 minutes ago Author Share Posted 10 minutes ago 1 hour ago, Danp2 said: There's a FAQ in the wiki for specifying the location of the browser executable -- https://www.autoitscript.com/wiki/WebDriver#FAQ $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "binary":"C:\\Path\\To\\Alternate\\Browser\\chrome.exe" }}}}' This format is wrong. \\ To be written as// Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now