【问题标题】:How can I select drop down menu and click on the drop down item with watir webdriver如何选择下拉菜单并使用 watir webdriver 单击下拉项
【发布时间】:2016-08-24 09:07:47
【问题描述】:

我点击下拉菜单的代码:

browser.select_list(:class => "ui-select-match").click

要从列表中选择的我的代码:

browser.select_list(:name => "system-parameter").clear
puts browser.select_list(:name => "system-parameter").options
browser.select_list(:name => "system-parameter").select("Brand")

HTML 点击下拉菜单:

<div class="ui-select-match" ng-hide="$select.open" ng-disabled="$select.disabled" ng-class="{'btn-default-focus':$select.focus}" placeholder="Select System Parameter">
    <span tabindex="-1" class="btn btn-default form-control ui-select-toggle" aria-label="Select box activate" ng-disabled="$select.disabled" ng-click="$select.activate()" style="outline: 0;">
    <span ng-show="$select.isEmpty()" class="ui-select-placeholder text-muted ng-binding">Select System Parameter</span> 
    <span ng-hide="$select.isEmpty()" class="ui-select-match-text pull-left ng-hide" ng-class="{'ui-select-allow-clear': $select.allowClear &amp;&amp; !$select.isEmpty()}" ng-transclude="">
    <span class="ng-binding ng-scope"></span>
    </span> <i class="caret pull-right" ng-click="$select.toggle($event)">
    </i> <a ng-show="$select.allowClear &amp;&amp; !$select.isEmpty()" aria-label="Select box clear" style="margin-right: 10px" ng-click="$select.clear($event)" class="btn btn-xs btn-link pull-right ng-hide">
    <i class="glyphicon glyphicon-remove" aria-hidden="true">
    </i>
    </a>
    </span>
    </div>

要从列表中选择的 HTML 代码:

<a href="javascript:void(0)" class="ui-select-choices-row-inner" uis-transclude-append="">
<div ng-bind-html="constant.Value | highlight: $select.search" name="Brand" class="ng-binding ng-scope">Brand</div>
</a>

<a href="javascript:void(0)" class="ui-select-choices-row-inner" uis-transclude-append="">
<div ng-bind-html="constant.Value | highlight: $select.search" name="Group" class="ng-binding ng-scope">Group</div>
</a>

<a href="javascript:void(0)" class="ui-select-choices-row-inner" uis-transclude-append="">
<div ng-bind-html="constant.Value | highlight: $select.search" name="Unit" class="ng-binding ng-scope">Unit</div>
</a>

我正在尝试单击下拉列表,但也无法从列表中进行选择。

【问题讨论】:

  • 根据您提供的 HTML,您没有选择列表。 select_list 用于与 &lt;select&gt; 元素交互。您有一个 diva 元素,它们的样式看起来像一个选择列表。

标签: ruby web-applications automation watir watir-webdriver


【解决方案1】:

您需要按照 ruby​​ 文档的建议对 select 标记内的元素使用 select_list

在这里查看更多 Class::Watir::SelectList

【讨论】:

  • 除了——正如贾斯汀在 cmets 中指出的——示例 HTML 中没有 &lt;select&gt; 标记。
  • 在我的 HTML 代码中没有选择列表,所以我无法编写脚本。
猜你喜欢
  • 2015-06-16
  • 1970-01-01
  • 2019-05-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-22
  • 2017-10-29
  • 2015-07-27
  • 2023-03-31
相关资源
最近更新 更多