Passing command line arguments to phantomjs.exe

1,222 views
Skip to first unread message

Ron Inbar

unread,
Apr 2, 2013, 5:49:13 AM4/2/13
to seleniu...@googlegroups.com
Hi,

I just found out that in Selenium 2.31.0 there is built-in support for PhantomJS/GhostDriver, using the system property phantomjs.binary.path.
Is there a similar property that allows Selenium to pass additional command-line arguments to PhantomJS?

Thanks,

Ron

Aniket Gadre

unread,
Apr 2, 2013, 5:51:11 AM4/2/13
to seleniu...@googlegroups.com
You can pass it by adding desired capabilities


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/bI-cew7OE1oJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Best Regards,
Aniket Gadre
Test Automation Lead
Amdocs , Pune.
E-add: aniket...@amdocs.com

Ron Inbar

unread,
Apr 2, 2013, 5:52:18 AM4/2/13
to seleniu...@googlegroups.com
Which capability can I use to disable loading images?


--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/vP2OrthK_R4/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.

Aniket Gadre

unread,
Apr 2, 2013, 6:01:18 AM4/2/13
to seleniu...@googlegroups.com
Example: I don't know whats the exact command line param for disabling loading of images but same name should be used here too

PhantomJSOptions pjsO = new PhantomJSOptions();
                    pjsO.AddAdditionalCapability("phantomjs.page.settings.userAgent", " Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");
                    pjsO.AddAdditionalCapability("phantomjs.page.settings.userName", "xyz\\abcd");
                    pjsO.AddAdditionalCapability("phantomjs.page.settings.password", "fdfdsfsf");
                    pjsO.AddAdditionalCapability("ignore-ssl-errors", true);
                    pjsO.AddAdditionalCapability("proxy", "10.19.170.175:8080");

Ron Inbar

unread,
Apr 2, 2013, 6:24:22 AM4/2/13
to seleniu...@googlegroups.com
What you're suggesting doesn't seem to work through the wire protocol (which I have to use, since my code is in PHP). As you can see in the following transcript, the Desired Capabilities included "ignore-ssl-errors" but the Negotiated Capabilities don't include such a capability, probably because it's not recognized by GhostDriver.

Next, I'm going to try launching phantomjs independently with the required command line arguments and attaching it to a Selenium Grid hub using --webdriver-selenium-grid-hub.

Regards,

Ron

13:12:28.340 INFO - Executing: [new session: {platform=ANY, browserName=phantomjs, version=, ignore-ssl-errors=true}] at URL: /session)
PhantomJS is launching GhostDriver...
[INFO  - 2013-04-02T10:12:28.947Z] GhostDriver - Main - running on port 40053
[INFO  - 2013-04-02T10:12:29.360Z] Session [d358b6c0-9b7d-11e2-bfdc-53bec20dafbd] - CONSTRUCTOR - Desired Capabilities: {"platform":"ANY","browserName":"phantomjs","version":"","ignore-ssl-errors":true}
[INFO  - 2013-04-02T10:12:29.360Z] Session [d358b6c0-9b7d-11e2-bfdc-53bec20dafbd] - CONSTRUCTOR - Negotiated Capabilities: {"browserName":"phantomjs","version":"1.9.0","driverName":"ghostdriver","driverVersion":"1.0.3","platform":"windows-7-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"d
atabaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO  - 2013-04-02T10:12:29.360Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: d358b6c0-9b7d-11e2-bfdc-53bec20dafbd
13:12:29.366 INFO - Done: /session
13:12:29.368 INFO - Executing: org.openqa.selenium.remote.server.handler.GetSessionCapabilities@79e4de3d at URL: /session/c3260af7-9854-468f-9220-44d41857c5b9)
13:12:29.368 INFO - Done: /session/c3260af7-9854-468f-9220-44d41857c5b9
13:12:29.381 INFO - Executing: org.openqa.selenium.remote.server.handler.GetSessionCapabilities@1c2c2958 at URL: /session/c3260af7-9854-468f-9220-44d41857c5b9)
13:12:29.382 INFO - Done: /session/c3260af7-9854-468f-9220-44d41857c5b9

Ron Inbar

unread,
Apr 3, 2013, 2:51:11 AM4/3/13
to seleniu...@googlegroups.com
I set up a Selenium grid hub on port 4444 and then launched phantomjs using this command line:
phantomjs --webdriver --webdriver-selenium-grid-hub=http://localhost:4444 --load-images=false
Although this method is a bit cumbersome, it seems to do the trick.

Regards,

Ron
Reply all
Reply to author
Forward
0 new messages