Jump to content

Recommended Posts

Posted

Hello!

I've been trying to launch chrome through WD,  but for some reason, the user profile is not working, it just opens up the chrome window with the "temp" user. I've also made sure that the user profile path is correct by using "chrome://version". 

Here is what I've got so far:

#include "wd_helper.au3"
#include "wd_capabilities.au3"
#include "wd_core.au3"

SetupChrome()

    _WD_CapabilitiesStartup()
    Local $sCapabilities = _WD_CapabilitiesGet()
    $sSession = _WD_CreateSession($sCapabilities)
    _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')
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Profile 2"]}}}}'
$_WD_DEBUG = $_WD_DEBUG_None ; You could also use $_WD_DEBUG_Error
EndFunc

 

Thanks in advance!

 

Posted
50 minutes ago, corvo said:

I've also made sure that the user profile path is correct by using "chrome://version".

It might be helpful it you showed us what was displayed there.

Quote
_WD_Option('DriverParams', '--marionette-port 2828')

Marionette only applies to Firefox, so this doesn't belong here.

Quote
    _WD_CapabilitiesStartup()
    Local $sCapabilities = _WD_CapabilitiesGet()

You manually defined the Capabilities in SetupChrome, so these lines aren't needed.

Quote
$_WD_DEBUG = $_WD_DEBUG_None

Please remove or comment out this line and then show us the complete output from running your code above.

Posted

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!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...