Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.

How to set a proxy for webdriver? Via command-line or capabilities? #12420

Closed
boogheta opened this issue Aug 5, 2014 · 12 comments
Closed

How to set a proxy for webdriver? Via command-line or capabilities? #12420

boogheta opened this issue Aug 5, 2014 · 12 comments

Comments

@boogheta
Copy link

boogheta commented Aug 5, 2014

I noticed that when running phantomjs with webdriver and a proxy from the command-line (phantomjs-1.9.7 --proxy=proxyhost:3128 --webdriver=33828 for instance), then my phantom sessions do not mention any use of the proxy:

[INFO - 2014-08-05T13:51:48.042Z] Session [a4f0d400-1ca7-11e4-8775-2d27219bffd9] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"1.9.7", "driverName":"ghostdriver", "driverVersion":"1.1.0", "platform":"linux-unknown-64bit", "javascriptEnabled":true, "takesScreenshot":false, "handlesAlerts":false, "databaseEnabled":false, "locationContextEnabled":false, "applicationCacheEnabled":false, "browserConnectionEnabled":false, "cssSelectorsEnabled":true, "webStorageEnabled":false, "rotatable":false, "acceptSslCerts":false, "nativeEvents":true,
"proxy":{"proxyType":"direct"},
"phantomjs.page.settings.userAgent":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20130330 Firefox/21.0","phantomjs.page.settings.javascriptCanOpenWindows":false,"phantomjs.page.settings.javascriptCanCloseWindows":false}

I assume this means the webdriver is already using the proxy, and then the phantom sessions through the webdriver do not need to use the proxy since it is already being used, but I just wanted to be sure and know whether I should rather:

  • stay as such and only set the proxy in command line?
  • forget about the command lien option and set the proxy in the capabilities for each session?
  • or even set it up in both places?
@OndraM
Copy link

OndraM commented Nov 10, 2014

From my experience the CLI arguments are the only ones that work. Using DesiredCapabilities is not working, so the output of negotiatedCapabilities is meaningless...
#11619 (comment)

@boogheta
Copy link
Author

Thanks, thtat's what I ended up understanding making a few tryouts by accessing a personal server from various phantom configs.

@kenju254
Copy link

@OndraM if desired capabilities is not working then what it the work around on this?

@OndraM
Copy link

OndraM commented Jan 8, 2015

@kenju254 I must start the phantomjs with command line options, like --proxy=foo.bar:8080, which is really inconvenient and also confusing, as other browsers accepts proxy settings through the capabilities.

@Accagain2014
Copy link

@OndraM Have you found a solution now?

@kenju254
Copy link

kenju254 commented Aug 3, 2015

@Accagain2014 and @OndraM i succeeded to get a solution to this . i must have forgotten to share

@Accagain2014
Copy link

@kenju254 Can you share with us?

@Accagain2014
Copy link

@boogheta Have you solved this problem? This troubles me a lot now. I can't find a way.

@boogheta
Copy link
Author

boogheta commented Aug 4, 2015

@Accagain2014: As @OndraM said, you shouldn't trust the negotiatedCapabilities outputted in the log. If you run phantom from command line with the --proxy= option it does use it although the log do not say so.
If that troubles you and you want to be sure, you can test it by accessing via phantom+proxy a local server you run and check the IP in the log for instance.

@Accagain2014
Copy link

@boogheta I think it's a phantomjs problem, not the ghostdriver problem.
I use phantomjs --proxy=127.0.0.1:3128 test.js to check if check phantomjs, It returns a lot of errors.
So I don't think it's a webdriver or capabilities problem.
but I use curl -x 127.0.0.1:3128 url, It works. That proves that my proxy works.
How to solve the problem? I know phantomjs-2.0.0 has a setProxy() function, but It hasn't binary file in Linux.
I use phantomjs 1.9.7

@boogheta
Copy link
Author

boogheta commented Aug 4, 2015

This proves your proxy works, not that your call with Phantom does not use it. You say you have errors, can you paste them? Maybe your problems rely in your test.js code?

@Accagain2014
Copy link

@boogheta I just opened a issue #13463

The error I got:
SyntaxError: Parse error

SyntaxError: Parse error

ReferenceError: Can't find variable: $s

http://weixin.sogou.com/weixin?query=dsfsdf&fr=sgsearch&type=2&w=01019900&sut=1635&sst0=1438676010824&lkt=0%2C0%2C0:696
SyntaxError: Parse error

ReferenceError: Can't find variable: cutLength

http://weixin.sogou.com/weixin?query=dsfsdf&fr=sgsearch&type=2&w=01019900&sut=1635&sst0=1438676010824&lkt=0%2C0%2C0:854
http://weixin.sogou.com/weixin?query=dsfsdf&fr=sgsearch&type=2&w=01019900&sut=1635&sst0=1438676010824&lkt=0%2C0%2C0:855
ReferenceError: Can't find variable: cutLength

http://weixin.sogou.com/weixin?query=dsfsdf&fr=sgsearch&type=2&w=01019900&sut=1635&sst0=1438676010824&lkt=0%2C0%2C0:858
ReferenceError: Can't find variable: vrTimeHandle552write

http://weixin.sogou.com/weixin?query=dsfsdf&fr=sgsearch&type=2&w=01019900&sut=1635&sst0=1438676010824&lkt=0%2C0%2C0:858
SyntaxError: Parse error

ReferenceError: Can't find variable: cutLength

http://weixin.sogou.com/weixin?query=dsfsdf&fr=sgsearch&type=2&w=01019900&sut=1635&sst0=1438676010824&lkt=0%2C0%2C0:887
ReferenceError: Can't find variable: vrTimeHandle552write

http://weixin.sogou.com/weixin?query=dsfsdf&fr=sgsearch&type=2&w=01019900&sut=1635&sst0=1438676010824&lkt=0%2C0%2C0:887
ReferenceError: Can't find variable: cutLength

http://weixin.sogou.com/weixin?query=dsfsdf&fr=sgsearch&type=2&w=01019900&sut=1635&sst0=1438676010824&lkt=0%2C0%2C0:912
http://weixin.sogou.com/weixin?query=dsfsdf&fr=sgsearch&type=2&w=01019900&sut=1635&sst0=1438676010824&lkt=0%2C0%2C0:913
ReferenceError: Can't find variable: cutLength

http://weixin.sogou.com/weixin?query=dsfsdf&fr=sgsearch&type=2&w=01019900&sut=1635&sst0=1438676010824&lkt=0%2C0%2C0:916
ReferenceError: Can't find variable: vrTimeHandle552write

http://weixin.sogou.com/weixin?query=dsfsdf&fr=sgsearch&type=2&w=01019900&sut=1635&sst0=1438676010824&lkt=0%2C0%2C0:916
ReferenceError: Can't find variable: cutLength

http://weixin.sogou.com/weixin?query=dsfsdf&fr=sgsearch&type=2&w=01019900&sut=1635&sst0=1438676010824&lkt=0%2C0%2C0:939
http://weixin.sogou.com/weixin?query=dsfsdf&fr=sgsearch&type=2&w=01019900&sut=1635&sst0=1438676010824&lkt=0%2C0%2C0:940

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants