SkysLastChance Posted yesterday at 04:46 PM Posted yesterday at 04:46 PM (edited) $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}' Getting this error from the chromedriver: DevTools remote debugging requires a non-default data directory. Specify this using --user-data-dir. However, I have set the --user-data in the $sDesiredCapabilites. Can someone help and tell me what I am doing wrong?ย #include "wd_core.au3" #include "wd_helper.au3" _WD_Option('Driver', 'chromedriver.exe') Local $iPort = _WD_GetFreePort(5555, 5600) _WD_Option('Port', $iPort) _WD_Option('DriverParams', '--port=' & $iPort & ' --verbose --log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}' _WD_Startup() Local $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_LoadWait($sSession) _WD_Navigate($sSession, "google.com") _WD_LoadWait($sSession) ย Edited yesterday at 04:50 PM by SkysLastChance You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott
Solution SOLVE-SMART Posted yesterday at 05:27 PM Solution Posted yesterday at 05:27 PM (edited) Hi @SkysLastChanceย ๐ , unfortunately Google did some important changes by v136. I guess this should be helpful for you: https://developer.chrome.com/blog/remote-debugging-port The following code is untested, but should ๐ค work: Local $sProfilePath = @UserProfileDir & '\AppData\Local\Google\Chrome\AutomationProfile' $sProfilePath = StringReplace($sProfilePath, '\', '\\') Local Const $sDesiredCapabilities = StringFormat( _ '{' & _ ' "capabilities": {' & _ ' "firstMatch": [' & _ ' {}' & _ ' ],' & _ ' "alwaysMatch": {' & _ ' "browserName": "chrome",' & _ ' "goog:chromeOptions": {' & _ ' "args": [' & _ ' "--remote-debugging-port=9222",' & _ ' "--user-data-dir=%s",' & _ ' "--profile-directory=Default"' & _ ' ]' & _ ' }' & _ ' }' & _ ' }' & _ '}', $sProfilePath) I added --remote-debugging-port and changed the profile path ($sProfilePath). Let me/us know if this helps ๐ค . Best regards Sven Edited yesterday at 06:23 PM by SOLVE-SMART SkysLastChance 1 ==> AutoIt related: ๐ GitHub, ๐ Discord Server, ๐ Cheat Sheet Spoiler ๐ย Au3Forums ๐ฒ AutoIt (en) Cheat Sheet ๐ AutoIt limits/defaults ๐ Code Katas: [...] (comming soon) ๐ญ Collection of GitHub users with AutoIt projects ๐ย False-Positives ๐ฎย Me on GitHub ๐ฌย Opinion about new forum sub category ๐ย UDF wiki list โย VSCode-AutoItSnippets ๐ย WebDriver FAQs ๐จโ๐ซย WebDriver Tutorial (coming soon)
SkysLastChance Posted yesterday at 06:23 PM Author Posted yesterday at 06:23 PM #include "wd_core.au3" #include "wd_helper.au3" ; Create profile directory if it doesn't exist Local $sUserDataDir = "C:\Script Prerequisites\ChromeDriverProfile" If Not FileExists($sUserDataDir) Then DirCreate($sUserDataDir) EndIf _WD_Option('Driver', 'chromedriver.exe') Local $iPort = _WD_GetFreePort(5555, 5600) _WD_Option('Port', $iPort) _WD_Option('DriverParams', '--port=' & $iPort & ' --verbose --log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["user-data-dir=C:\\Script Prerequisites\\ChromeDriverProfile", "--profile-directory=Default", "--disable-extensions"], "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false }}}}' _WD_Startup() Local $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_LoadWait($sSession) _WD_Navigate($sSession, "google.com") _WD_LoadWait($sSession) I did this but your solution was better. @SOLVE-SMART Thank you! You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott
SOLVE-SMART Posted yesterday at 06:30 PM Posted yesterday at 06:30 PM (edited) 7 minutes ago, SkysLastChance said: I did this but your solution was better. @SOLVE-SMART Thank you! I'm glad it works. You're welcome. ๐ก Btw: In case you want to avoid the json creation (capability string) on your own, you can use _WD_CapabilitiesAdd to create the string. So no struggle with characters like { " : [ etc. Best regards Sven Edited yesterday at 06:31 PM by SOLVE-SMART ==> AutoIt related: ๐ GitHub, ๐ Discord Server, ๐ Cheat Sheet Spoiler ๐ย Au3Forums ๐ฒ AutoIt (en) Cheat Sheet ๐ AutoIt limits/defaults ๐ Code Katas: [...] (comming soon) ๐ญ Collection of GitHub users with AutoIt projects ๐ย False-Positives ๐ฎย Me on GitHub ๐ฌย Opinion about new forum sub category ๐ย UDF wiki list โย VSCode-AutoItSnippets ๐ย WebDriver FAQs ๐จโ๐ซย WebDriver Tutorial (coming soon)
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