SkysLastChance Posted 13 hours ago Posted 13 hours ago (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 13 hours ago by SkysLastChance You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott
Solution SOLVE-SMART Posted 12 hours ago Solution Posted 12 hours ago (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 11 hours ago 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 11 hours ago Author Posted 11 hours ago #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 11 hours ago Posted 11 hours ago (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 11 hours ago 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)
Nine Posted 8 hours ago Posted 8 hours ago Are you able to use your actual account this way ?ย โThey did not know it was impossible, so they did itโย โ Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text ย Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker ย Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC ย HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet ย Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector ย Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF ย Multi-Threading Made Easy Interface Object based on Tag ย
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