小编Rag*_*n.B的帖子

选择第二个下拉值Watir-Webdriver

设计:

第一次下拉:

<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)

ruby watir

1
推荐指数
1
解决办法
4896
查看次数

标签 统计

ruby ×1

watir ×1