Watir Webdriver的mobile测试

上一篇 / 下一篇  2013-01-27 14:52:21 / 个人分类:测试

实际上,Watir Webdriver可以测试的仍然是Site,不是APP,可以用于测试mobile device访问的mobile site的方式有三种:

1. 在一个真实的设备上,利用内置的browser进行测试
2. 在一个仿真的设备上,利用内置的browser进行测试
3. 在pc机上,将browser设置为mobile browser进行测试

对于在真实设备上进行测试,速度会相对比较慢,而且iOS还需要额外的费用。

而且还需要在iOs和Android的设备上先安装相应的driver。

所以最简单的方法,就是利用webdriver-user-agent gem 进行模拟测试

方法如下:

require 'watir-webdriver'
require 'webdriver-user-agent'
driver = UserAgent.driver(:browser => :chrome, :agent => :iphone, :orientation => :landscape)
browser = Watir::Browser.new driver
browser.goto 'tiffany.com'
browser.url.should == 'http://m.tiffany.com/International.aspx'


我们可以看到,最关键的就是:

driver = UserAgent.driver(:browser => :chrome, :agent => :iphone, :orientation => :landscape)

这个步骤,指明了你要使用的浏览器类型,仿真器类型,和视图方式。

该gem可以支持的浏览器有ff和chrome
可以支持的仿真器类型有:iphone, ipad, android_phone, 和android_tablet
支持的视图方式有两种,水平和竖直。 (portrait and landscape)


TAG:

 

评分:0

我来说两句

日历

« 2024-05-05  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 151735
  • 日志数: 185
  • 文件数: 6
  • 建立时间: 2007-08-06
  • 更新时间: 2015-01-06

RSS订阅

Open Toolbar