这是我第一次使用ruby和watir。我在Linux上安装了Firefox 45.4.0和ruby 2.4.1以及ruby gems 2.6.12和watir 6.2.1以及geckodriver-0.16.1 bsg-gnorris2 2.6.32-504.el6.x86_64#1 SMP Tue Sep 16 01:56:35 EDT 2014 x86_64 x86_64 x86_64 GNU / Linux
在大多数情况下,事情进展顺利。我在选择列表中选择项目时遇到问题。以下是创建选择列表的代码:
<div><div class="form-item form-item-court form-type-select form-group">
<label class="control-label" for="edit-court">Court
<span class="form-required" title="This field is required.">*</span></label>>
<select class="form-control form-select required" id="edit-court" name="court">
<option value="" selected="selected">- Select -</option>
<option value="1127">Alabama - Middle</option>
<option value="1126">Alabama - North</option>
<option value="1128">Alabama - South</option>
...
...
<option value="0757">Wisconsin - East</option>
<option value="0758">Wisconsin - West</option>
<option value="1089">Wyoming</option>
</select></div>
代码导航到具有上面选择列表的页面。 然后,当我尝试选择select_list选项时,没有任何反应,也不会产生错误消息。
以下是我的尝试:
browser.select_list(:id => 'edit-court').select_value '1126'
(nothing visible happens - no error messages)
browser.select_list(:id => 'edit-court').select 'Alabama - North'
(nothing visible happens - no error messages)
browser.select_list(:id => 'edit-court').select /Alabama - North/
(nothing visible happens - no error messages)
browser.element(:id => 'edit-court').wait_until_present.click (this shows list options)
browser.element(:id => 'edit-court').option(:value, '1126').wait_until_present.select (this hides list options)
browser.element(:id => 'edit-court').wait_until_present.click (this shows list options)
browser.element(:id => 'edit-court').option(:value, '1126').wait_until_present.click (this hides list options)
browser.element(:id => 'edit-court').wait_until_present.click (this shows list options)
browser.select_list(:id => 'edit-court').options[3].click (hides the list options)
我不知道接下来要做什么。有什么建议吗?