Jump to content

Chrome webdriver - use different port


 Share

Go to solution Solved by Danp2,

Recommended Posts

This new question is related to this: https://www.autoitscript.com/forum/topic/206887-chrome-webdriver-download-file/

Script is the same, working OK now.

I need to run multiple instances. Different profile folders is solved.

But it seems it also needs different port.

So I changed this:

_WD_Option('Port', 9517)

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false, "args":["user-data-dir=' & $user_profile & '", "port=9517"], "prefs": {"download.default_directory": "' & $download_directory & '"} }}}}'

It doesn't work. Command line output is always port 9515

Starting ChromeDriver 96.0.4664.45 (76e4c1bb2ab4671b8beba3444e61c0f17584b2fc-refs/branch-heads/4664@{#947}) on port 9515

AutoIt Console seems to be 9517:

_WDStartup: Port:   9517
__WD_Post: URL=HTTP://127.0.0.1:9517/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false, "args":["user-data-dir=D:\\Diverse", "port=9517"], "prefs": {"download.default_directory": "g:\\folder\\"} }}}}


__WD_Post: URL=HTTP://127.0.0.1:9517/session//element//click; $sData={"id":""}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver

If I switch back to 9515 it works perfectly.

 

Edited by queensoft
Link to comment
Share on other sites

It is starting with different port, yes, the solution worked great.

But I'm unable to start multiple instances.

When I start the second instance, the first one is automatically closed - the webdriver command line output window is closed.

The first  autoit instance and the first chrome window are left untouched - but not working, obviously, since the webdriver is gone.

The second instance then continues OK.

If I start 3rd instance > second is closed.... and so on.

I'll try to get error messages.

 

Later edit: I think problem is this

---------------------------
WD_Core.au3 Error:
---------------------------
__WD_Post ==> Invalid argument: {"value":{"error":"invalid argument","message":"invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir","stacktrace":"Backtrace:\n\tOrdinal0 [0x00496903+2517251]\n\tOrdinal0 [0x0042F8E1+2095329]\n\tOrdinal0 [0x00332848+1058888]\n\tOrdinal0 [0x0034D8AB+1169579]\n\tOrdinal0 [0x0034A2CF+1155791]\n\tOrdinal0 [0x0037AAAF+1354415]\n\tOrdinal0 [0x0037A71A+1353498]\n\tOrdinal0 [0x0037639B+1336219]\n\tOrdinal0 [0x003527A7+1189799]\n\tOrdinal0 [0x00353609+1193481]\n\tGetHandleVerifier [0x00625904+1577972]\n\tGetHandleVerifier [0x006D0B97+2279047]\n\tGetHandleVerifier [0x00526D09+534521]\n\tGetHandleVerifier [0x00525DB9+530601]\n\tOrdinal0 [0x00434FF9+2117625]\n\tOrdinal0 [0x004398A8+2136232]\n\tOrdinal0 [0x004399E2+2136546]\n\tOrdinal0 [0x00443541+2176321]\n\tBaseThreadInitThunk [0x767DFA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x771D7A9E+286]\n\tRtlGetAppContainerNamedObjectPath [0x771D7A6E+238]\n"}}
---------------------------
OK   
---------------------------

But still not working - very similar problem, previous webdriver window is closed, autoit & chrome are untouched.

Different port = OK, different user dir = OK.

Output - first part = OK, second part = problem, after launching second instance.

__WD_Post: URL=HTTP://127.0.0.1:9600/session/5270be65ce69b3a9f43822e4c26c475e/url; $sData={"url":"https://www.subtitlist.com/subtitle/suits-fourth-season/arabic/1385457"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Navigate: {"value":null}
__WD_Post: URL=HTTP://127.0.0.1:9600/session/5270be65ce69b3a9f43822e4c26c475e/element; $sData={"using":"xpath","value":"//a[@type='button']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"24b985c5-1c88-46cb-acd3-9ba667859b33"}}...
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"24b985c5-1c88-46cb-acd3-9ba667859b33"}}
__WD_Post: URL=HTTP://127.0.0.1:9600/session/5270be65ce69b3a9f43822e4c26c475e/element/24b985c5-1c88-46cb-acd3-9ba667859b33/click; $sData={"id":"24b985c5-1c88-46cb-acd3-9ba667859b33"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_ElementAction: {"value":null}...



__WD_Post: URL=HTTP://127.0.0.1:9600/session/5270be65ce69b3a9f43822e4c26c475e/url; $sData={"url":"https://www.subtitlist.com/subtitle/suits-fourth-season/arabic/1294544"}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_Navigate: WinHTTP request timed out before Webdriver
_WD_Navigate ==> Send / Recv error: HTTP status = 0

 

Edited by queensoft
Link to comment
Share on other sites

1) As mentioned in the prior linked thread, a single Chromedriver instance should be able to service multiple user sessions. Have you tried that?

2) There are multiple settings that you can configure with _WD_Option to control the driver instantiation. Take a look at both DriverClose and DriverDetect.

3) Each Chromedriver session needs to have its own unique profile.

Link to comment
Share on other sites

1) I think this is the problem: the chromedriver.exe is launched by multiple instances of AutoIt - different PIDs.

Main program = only one instance

Main program > start SUB program (instance 1) > start chromedriver.exe (1) > pages loading OK, download files OK  in folder 1

Main program > start SUB program (instance 2) > start chromedriver.exe (2) > first chromedriver window dissapears, a new one appears > download files OK in folder 2; no new files in folder 1, no more page load in first Chrome window - see error above:

__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...

Maybe the chromedriver.exe has to be started by the same instance of AutoIt program, same PID ?

 

2) I will take a look.

 

3) Already done, unique folders for each.

Edited by queensoft
Link to comment
Share on other sites

48 minutes ago, queensoft said:

1) I think this is the problem: the chromedriver.exe is launched by multiple instances of AutoIt - different PIDs.

Not AFAIK, but this isn't something that I've needed so I haven't done extensive testing. Can you provide a short example that demonstrates the problem?

49 minutes ago, queensoft said:

3) Already done, unique folders for each.

Not sure how you would be getting this error if that was the case --

Quote
__WD_Post ==> Invalid argument: {"value":{"error":"invalid argument","message":"invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir"

 

Link to comment
Share on other sites

I will try to send a quick test program tomorrow morning.

I have added this but doesn't help.

_WD_Option('DriverClose', False)
    _WD_Option('DriverDetect', True)

Unique folder - it is fixed, that error is no longer present.

The only error I get is this: first part = OK, second part = problem, after launching second instance.

__WD_Post: URL=HTTP://127.0.0.1:9600/session/5270be65ce69b3a9f43822e4c26c475e/url; $sData={"url":"https://www.subtitlist.com/subtitle/suits-fourth-season/arabic/1385457"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Navigate: {"value":null}
__WD_Post: URL=HTTP://127.0.0.1:9600/session/5270be65ce69b3a9f43822e4c26c475e/element; $sData={"using":"xpath","value":"//a[@type='button']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"24b985c5-1c88-46cb-acd3-9ba667859b33"}}...
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"24b985c5-1c88-46cb-acd3-9ba667859b33"}}
__WD_Post: URL=HTTP://127.0.0.1:9600/session/5270be65ce69b3a9f43822e4c26c475e/element/24b985c5-1c88-46cb-acd3-9ba667859b33/click; $sData={"id":"24b985c5-1c88-46cb-acd3-9ba667859b33"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_ElementAction: {"value":null}...



__WD_Post: URL=HTTP://127.0.0.1:9600/session/5270be65ce69b3a9f43822e4c26c475e/url; $sData={"url":"https://www.subtitlist.com/subtitle/suits-fourth-season/arabic/1294544"}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_Navigate: WinHTTP request timed out before Webdriver
_WD_Navigate ==> Send / Recv error: HTTP status = 0

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...