Google 制作AJAX应用程序的完整规范Crawlable建议使用HTMLUnit ...请参阅如何创建HTML快照?第3点.
HtmlUnit是一个仅限Java的无头浏览器模拟器; 不幸的是,jRuby不是Heroku的选项.所以HtmlUnit被排除了(据我所知).
如果你感兴趣我还有另外一个问题,关于HtmlUnit作为托管在Google App Engine上的服务...... 让AJAX应用程序可以抓取吗?如何在Google App Engine上构建简单的Web服务来生成HTML快照?......仍在等待一个经过验证的例子/答案.
客户名称是包含近30个值的下拉列表,我想从Watir脚本的下拉列表中选择一个值.
我使用了以下代码,但没有发生任何事情.
ie.select_list(:name,"Customers").选择"测试"
使用Watir进行测试时如何使用测试用户名和密码添加步骤/代码以登录测试站点?此外,我不知道如何从小方框中获取用户名和密码的字段名称.
谢谢
在我正在测试的网页上,当用户单击选择列表中的选项时,将进行GET调用.GET看起来像这样:
GET /mediaportal/captions/SCH/Follow%20Up%20with%20the%20Robles%20Family_SCH.xml
Run Code Online (Sandbox Code Playgroud)
如何告诉Ruby监听GET请求并捕获它,或者更具体地说,捕获并将上面GET中请求的url放入变量中.
(我正在使用watir-webdriver gem,我希望那里有一些东西可以让我这样做.)
我正在使用watir-cucumber进行测试自动化。我单独编写了以下方法.rb
,该方法不在步骤定义中。
def has_logged_in?
$browser.text.should include("t788")
end
Run Code Online (Sandbox Code Playgroud)
当我从步骤定义中调用此方法时,就会出现此错误,
wrong argument type String (expected Module) (TypeError)
Run Code Online (Sandbox Code Playgroud)
相同的代码在步骤定义中效果很好。我四处搜索,发现该include
方法用于包含模块,但这是ruby-include
method并should include
在下面rspec\expectations
。因此,如何在should include
上述步骤定义之外调用方法。我在Linux上使用watir-cucumber
作为我们Watir测试套件的一部分,我们正在验证数据表.其中一个要求是特定列必须为空(除非选择了特定的单选按钮)所以在我的脚本中,我有以下代码
incidents = browser.table(:xpath, Xpath_CC).strings
Run Code Online (Sandbox Code Playgroud)
浏览器是watir-webdriver浏览器对象在事件中提供我的这个2d数组
[["DateTime", "Problem", "Value", "Compared", "Number", "Causes", "Where", "Count", "Type"],
["May 07, 02:15 - 02:30", "Web", "38.46 %", "", "1", "UNKNOWN", "", "1", "J105"],
["May 07, 02:15 - 02:30", "Video", "40 %", "", "1", "UNKNOWN", "", "1", "J105"],
["May 07, 02:00 - 02:15", "Email", "30 %", "", "1", "UNKNOWN", "", "1", "J105"],
["May 07, 01:00 - 01:15", "Email", "70 %", "", "1", "UNKNOWN", "", "1", "J105"],
["May 07, 01:00 - 01:15", "Email", "70 %", "", …
Run Code Online (Sandbox Code Playgroud) 我试图匹配网站中的元描述,但无法通过HTML实体.我试过逃避角色和其他一些组合.如果您尝试匹配没有实体的文本区域,则没有问题.任何帮助都是适用的.
require "rubygems"
require "watir-webdriver"
include Watir
b = Watir::Browser.new :chrome
b.goto('http://dev01-new.firestonecompleteautocare.com/cf/oil-change/motor-oil-and-your-car')
if b.metas.any?{ |s| s.html.include? "Ever wonder what color your engine oil should
be, or what affect temperature may have on it? Learn the answers to these
frequently asked questions & more, here." }
puts 'Yes'
else
puts 'No'
end
b.close
Run Code Online (Sandbox Code Playgroud) 第一次下拉:
<select id="MainContent_drpVehicleType" style="width:175px;" name="ctl00$MainContent$drpVehicleType">
<option value="">- SELECT -</option>
<option value="1" title="AUTO">AUTO</option>
<option value="2" title="HD">HD</option>
<option value="3" title="MARINE">MARINE</option>
</select>
Run Code Online (Sandbox Code Playgroud)
第二次下拉:
<select id="MainContent_drpMake" style="width:175px;" name="ctl00$MainContent$drpVehicleType">
<option value="1" title="ACURA">ACURA</option>
<option value="2" title="ALFA ROMEO">ALFA ROMEO</option>
<option value="74" title="ALLIS CHALMERS LIFT TRUCK">ALLIS CHALMERS LIFT TRUCK</option>
<option value="75" title="ALLIS CHALMERS TRACTOR">ALLIS CHALMERS TRACTOR</option>
<option value="4" title="AMERICAN MOTORS">AMERICAN MOTORS</option
</select>
Run Code Online (Sandbox Code Playgroud)
b.select_list(:id, "MainContent_drpVehicleType").select("AUTO")
b.select_list(:id, "MainContent_drpMake").select("ACURA")
Run Code Online (Sandbox Code Playgroud)
并尝试过
`b.select_list(:id, "MainContent_drpMake").wait_until_present.option(:text, 'ACURA')`
Run Code Online (Sandbox Code Playgroud)
**我的问题是从第一次下拉菜单中选择"自动"并且无法从第二次下拉菜单中选择"ACURA"
C:/Ruby193/menu.rb:23:in `<main>':
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.2/lib/watir-webdriver/el
ements/select.rb:218:in `no_value_found': "ACURA" not found in select list (Wati
r::Exception::NoValueFoundException)
from …
Run Code Online (Sandbox Code Playgroud) 我正在尝试找到一组复选框,但我需要在字段集中找到它们.html就像这样(它是一个gwt应用程序,因此产生了大量的东西:
<div id="UpdateUserView-RolesColumn">
<fieldset style="">
<legend>Primary Role</legend>
<select class="gwt-ListBox">
<option value="ROLE_GENERAL_USER">ROLE_GENERAL_USER</option>
<option value="ROLE_ADMIN">ROLE_ADMIN</option>
</select>
</fieldset>
<fieldset style="" class="createUser-otherRolesFieldset">
<legend>Other Roles / Permissions</legend>
<div style="overflow: auto; position: relative; zoom: 1; height: 250px;">
<div style="position: relative; zoom: 1;">
<div>
<span class="gwt-CheckBox">
<input type="checkbox" value="on" id="gwt-uid-760" tabindex="0" checked="">
<label for="gwt-uid-760">ROLE_BLAH1_USER</label>
</span>
<span class="gwt-CheckBox">
<input type="checkbox" value="on" id="gwt-uid-761" tabindex="0" checked="">
<label for="gwt-uid-761">ROLE_BLAH2_USER</label>
</span>
<span class="gwt-CheckBox">
<input type="checkbox" value="on" id="gwt-uid-762" tabindex="0" checked="">
<label for="gwt-uid-762">ROLE_BLAH3_USER</label>
</span>
<span class="gwt-CheckBox">
<input type="checkbox" value="on" id="gwt-uid-763" tabindex="0" checked="">
<label for="gwt-uid-763">ROLE_BLAH4_USER</label> …
Run Code Online (Sandbox Code Playgroud) 用户操作后,Web应用程序始终使用此div.我的测试脚本有这一行.逐字逐句.
@browser.div(:id => 'loading-indicator').wait_while_present
Run Code Online (Sandbox Code Playgroud)
在任何地方明确地包括这条线是可以的,但是丑陋和重复.
使用wait_until_present
与下一元素(" foo
负载指示后"),有时会工作.然而,在某些情况下foo
和负载指示同时存在,但foo
不是visible?
直到负载指示消失.
有没有办法,或许在env.rb
,向watir-webdriver表明它应该始终wait_while
存在这个元素?