SkysLastChance Posted May 6 Posted May 6 (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 May 6 by SkysLastChance You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott
Solution SOLVE-SMART Posted May 6 Solution Posted May 6 (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 May 6 by SOLVE-SMART SkysLastChance 1 ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet Reveal hidden contents 🌍 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 May 6 Author Posted May 6 #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 May 6 Posted May 6 (edited) On 5/6/2025 at 6:23 PM, SkysLastChance said: I did this but your solution was better. @SOLVE-SMART Thank you! Expand 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 May 6 by SOLVE-SMART ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet Reveal hidden contents 🌍 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