Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing User-Agent #70

Open
joshua-biz opened this issue Jul 12, 2019 · 0 comments
Open

Changing User-Agent #70

joshua-biz opened this issue Jul 12, 2019 · 0 comments

Comments

@joshua-biz
Copy link

I'm trying to change the User-Agent used with qtwebdriver, but have as of yet been unsuccessful.

From what I've read, this doesn't seem to be part of the selenium spec (See: SeleniumHQ/selenium-google-code-issue-archive#141), however many other webdriver implementations provide their own way of doing this. If this is already an implemented feature, I would appreciate some direction in how it can be changed, and if not I suppose its a feature request.

Chrome

from selenium import webdriver
chrome_opts = webdriver.ChromeOptions()
chrome_opts.add_argument('useragent="<User-Agent here>"')
driver = webdriver.Chrome(options=chrome_opts)

Firefox

from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_preferences("general.useragent.override", "<User-Agent here>")
driver = webdriver.Firefox(profile)

Phantom JS

from selenium import webdriver
phantom_opts = webdriver.DesiredCapabilities.PHANTOMJS
phantom_opts['phantomjs.page.settings.userAgent'] = '<User-Agent here>'
driver = webdriver.PhantomJS(desired_capabilities=phantom_opts)

Above are just for some working examples. Not working example I've tried for use with qtwebdriver:

from selenium import webdriver

capabilities = {'browserStartWindow': '*'}

chrome_opts = webdriver.ChromeOptions()
chrome_opts.add_argument('useragent="<User-Agent here>"')

# Connects fine, doesn't change user agent.
driver = webdriver.Remote(
    'http://127.0.0.1:9517', 
    desired_capabilities=capabilities,
    options=chrome_opts
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant