【发布时间】:2011-06-12 15:13:36
【问题描述】:
我正在尝试对从移动设备访问时行为不同的应用程序进行网络自动化。有谁知道使用 Selenium 2 实现这一目标的最佳方法?
在理想情况下,我想找到一种方法来配置用户代理,以便我们可以轻松地测试大量排列。
【问题讨论】:
标签: ruby firefox selenium selenium-webdriver webautomation
我正在尝试对从移动设备访问时行为不同的应用程序进行网络自动化。有谁知道使用 Selenium 2 实现这一目标的最佳方法?
在理想情况下,我想找到一种方法来配置用户代理,以便我们可以轻松地测试大量排列。
【问题讨论】:
标签: ruby firefox selenium selenium-webdriver webautomation
查看here,它显示了在Firefox中设置用户代理字符串的代码:
FirefoxProfile profile = new FirefoxProfile();
profile.addAdditionalPreference("general.useragent.override", "some UA string");
WebDriver driver = new FirefoxDriver(profile);
转换为 Ruby,它看起来像这样:
require 'selenium-webdriver'
profile = Selenium::WebDriver::Firefox::Profile.new
profile['general.useragent.override'] = 'some UA string'
driver = Selenium::WebDriver.for :firefox, :profile => profile
在其末尾添加一行以导航到 http://whatsmyuseragent.com 表示它按预期工作。
不过,Selenium 2 附带了适用于 iPhone 和 Android 应用程序的驱动程序。我还没有尝试过,但看起来它们要么在模拟器中运行,要么在真实设备中运行。有没有理由让这些对你不起作用?他们可能会更好地了解事物在设备上的真实外观。
【讨论】: