Thank you so much, it started working now after removing the extra unnecessary lines
- But now it only works in case no Chrome windows were open when I run the script, otherwise, it will start a new window, without navigating to the link. And when I remove the user profile tags from the capabilities, it starts working again (even if I've previously opened Chrome tabs).
Here is the updated code:
#include "wd_helper.au3"
#include "wd_capabilities.au3"
#include "wd_core.au3"
SetupChrome()
local $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Profile 2"]}}}}'
$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://www.google.com")
Func SetupChrome()
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')
_WD_Option('DriverParams', '--marionette-port 2828')
;~ $_WD_DEBUG = $_WD_DEBUG_None ;
EndFunc
Error Log (in case a Chrome window was already open).
_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\mm\autoit\SciTe\chrome.log"
_WD_Option ==> Success [0] : Parameters: Option=DriverParams Value=--marionette-port 2828
__WD_Post ==> Webdriver Exception [10] : HTTP status = 500
_WD_CreateSession ==> Webdriver Exception [10]
__WD_Post ==> Invalid session ID [15] : HTTP status = 404
_WD_Navigate ==> Invalid session ID [15] : Parameters: URL=https://www.google.com
Thank you for all the help!