Add custom header in Selenium and Sauce Labs?

南笙酒味 提交于 2019-12-06 10:45:54

I'm not familiar with Sauce Labs, but you can certainly do this on some Selenium setups, by changing the general.useragent.override, as follows (which may be adaptable):

Using the FirefoxDriver you can:

FirefoxProfile profile = new FirefoxProfile();
profile.addAdditionalPreference("general.useragent.override", "some UA string");
WebDriver driver = new FirefoxDriver(profile);

with Cabybara you can:

Capybara.register_driver :iphone do |app|
  require 'selenium/webdriver'
  profile = Selenium::WebDriver::Firefox::Profile.new
  profile['general.useragent.override'] = "iPhone"

  Capybara::Driver::Selenium.new(app, :profile => profile)
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!