我正在使用 Selenium Webdriver 和 Ruby 进行一些移动 Web 自动化测试。现在我需要传递用户代理以及我已经传递的远程 Webdriver 功能。有什么方法可以为 Mobile Web 设置用户代理?我将功能设置为 iphone 并使用 iPhone Simulator 运行我的测试。
问问题
948 次
2 回答
0
这是不可能的,因为 WebDriver 当前缺少 HTTP 响应标头和状态码方法。
此问题的链接:https ://code.google.com/p/selenium/issues/detail?id=141
于 2015-07-27T14:51:12.780 回答
-1
Try something like this
capabilities = Selenium::WebDriver::Remote::Capabilities.send(:firefox, :firefox_profile => build_mobile_profile)
profile = Selenium::WebDriver::Firefox::Profile.new
profile['general.useragent.override'] = "Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 30 # for example
browser = Watir::Browser.new(:remote,
:url => "https://selenium.yourdomain.com:4445/wd/hub",
:http_client => client,
:desired_capabilities => capabilities
)
于 2015-07-21T16:47:12.083 回答