Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

PhantomJS userAgent setting? #561

Closed
thybzi opened this issue Aug 24, 2016 · 5 comments
Closed

PhantomJS userAgent setting? #561

thybzi opened this issue Aug 24, 2016 · 5 comments

Comments

@thybzi
Copy link

thybzi commented Aug 24, 2016

I need to test my pages with PhantomJS with custom userAgent set.

That is, is there any hook available for thing like that:

var page = require('webpage').create();
page.settings.userAgent = 'My Custom UserAgent';

Could that be made anyhow? E.g. with desiredCapabilities in config, with suite actions, or in any else way?

Didn't find any key on this in documentation.

@sipayRT
Copy link
Member

sipayRT commented Aug 25, 2016

hi.

you can do it from the config:

desiredCapabilities: {
    browserName: 'chrome',
    version: 48,
    chromeOptions: {
        mobileEmulation: {
            userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_2 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/9.2 Mobile/12A4345d Safari/600.1.4'
        }
    }
}

@sipayRT
Copy link
Member

sipayRT commented Aug 25, 2016

more info here

@thybzi
Copy link
Author

thybzi commented Aug 25, 2016

@sipayRT You are speaking about ChromeDriver, that's no problem to set its settings with config as you mentioned.

But my question is about PhantomJS

@sipayRT
Copy link
Member

sipayRT commented Aug 25, 2016

sorry, but I don't know how to do it in phantomJS. you can ask phantomJS maintainers ;)

@sipayRT sipayRT closed this as completed Aug 26, 2016
@thybzi
Copy link
Author

thybzi commented Aug 28, 2016

Surely, I know how to do this on plain phantomjs:

var webPage = require('webpage');
var page = webPage.create();
page.settings.userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36';

(source: http://phantomjs.org/api/webpage/property/settings.html)

But don't know how to perform the same thing within gemini using phantomjs

Is there any chance to do this?

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

2 participants