Reputation: 2892
I've been trying to get PhantomJS ( 1.9.7 )/GhostDriver to be initialized with some custom settings for quite a while, but have been completely unsuccessful. I'm using wd.js as my WebDriver library, and I have tried just about every combination of properties that I can think of, however nothing has worked, and I haven't been able to find any documentation.
Here's what I have tried passing ( userAgent shortened for sanity, it's a real one in my actual test cases ):
{ browserName: "phantomjs", "userAgent": "foo" }
{ browserName: "phantomjs", "settings": { "userAgent": "foo" } }
{ browserName: "phantomjs", "page": { "userAgent": "foo" } }
{ browserName: "phantomjs", "page": { "settings": { "userAgent": "foo" } } }
{ browserName: "phantomjs", "phantomjs": { "page": { "userAgent": "foo" } } }
{ browserName: "phantomjs", "phantomjs": { page": { "settings": { "userAgent": "foo" } } } }
And lot's more actually, using just about every combination of keys that I could think of from https://github.com/detro/ghostdriver#what-extra-webdriver-capabilities-ghostdriver-offers .
Does anyone have any idea what you need to pass in order to customize settings in PhantomJS when using Webdriver/Ghostdriver?
Upvotes: 1
Views: 1101
Reputation: 2892
Ugh, well this was very unintuitive. When the documentation says that the property is phantomjs.page.settings.userAgent
, one would expect that it follows normal javascript conventions. Not so, the key is LITERALLY phantomjs.page.settings.userAgent
, so the answer to my question is:
{
"browserName": "phantomjs",
"phantomjs.page.settings.userAgent": "foo"
}
Upvotes: 2