当前位置: 首页 > 知识库问答 >
问题:

量角器 - 选择“下拉列表”时“不可见元素”。(但手动选择时可见)

江嘉悦
2023-03-14

我一直在搜索2天,但我无法找到解决方案,我想要一个下拉列表被选中。当我使用某些元素.all css定位器单击下拉列表时,它会单击下拉列表(下拉列表打开但显示错误)。所以我试图使用链接文本打开下拉列表(完美地打开)。但在那之后,我无法在下拉列表中选择该选项。(显示“不可见元素”)。我也无法通过链接文本选择该选项。以下是详细信息

<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right" style="margin-right:0px">
 <li>
    <div uib-dropdown="" style="margin-right: 5px;" class="dropdown">
                                Tenant
    <a href="" id="simple-dropdown" uib-dropdown-toggle="" class="dropdown-toggle" aria-haspopup="true" aria-expanded="false">
    <span class="breadcrumb ng-binding" style="padding-bottom: 2px; padding-top: 2px;">cust1</span>
    </a>
      <ul class="uib-dropdown-menu dropdown-menu" role="menu" aria-labelledby="single-button">
    <!-- ngRepeat: tenant in tenantList --><li ng-repeat="tenant in tenantList" class="ng-scope">
    <a ng-click="selectTenant(0)" href="">
    <span ng-show="selectedTenant.Identity == tenant.Identity" class="glyphicon glyphicon-ok"></span>
    <span ng-show="selectedTenant.Identity != tenant.Identity" style="margin-left: 17px" class="ng-hide"></span>
    <span class="ng-binding">cust1</span>
    </a>
    </li><!-- end ngRepeat: tenant in tenantList --><li ng-repeat="tenant in tenantList" class="ng-scope">
    <a ng-click="selectTenant(1)" href="">
    <span ng-show="selectedTenant.Identity == tenant.Identity" class="glyphicon glyphicon-ok ng-hide"></span>
    <span ng-show="selectedTenant.Identity != tenant.Identity" style="margin-left: 17px" class=""></span>
    <span class="ng-binding">NewTenant1</span>
     </a>
    </li><!-- end ngRepeat: tenant in tenantList --><li ng-repeat="tenant in tenantList" class="ng-scope">
    <a ng-click="selectTenant(2)" href="">
    <span ng-show="selectedTenant.Identity == tenant.Identity" class="glyphicon glyphicon-ok ng-hide"></span>
    <span ng-show="selectedTenant.Identity != tenant.Identity" style="margin-left: 17px" class=""></span>
    <span class="ng-binding">cust2</span>
    </a>
    </li><!-- end ngRepeat: tenant in tenantList -->
    </ul>
    </div> 

我试图通过以下方法来选择,但我不能让它工作。

  1. 等待元素变为可见。
  2. 链接文本
  3. 要选择的选项。(通过中继器名称作为选项)请帮助我

共有2个答案

颜森
2023-03-14

这就够了吗?我用它来标识包含特定标签值的下拉元素...

this.clickDropChoice = function(dropdown, optionChoice) {
    dropdown.element(by.cssContainingText('option', optionChoice)).click()
};
周峻
2023-03-14

元素(按.partialLinkText('cust2'));我不知道为什么linktext不起作用,但partialLinkText起作用了。谢谢你的回复。

 类似资料:
  • WebElement drpAmentization=driver.findElement(by.xpath(“//select[@id='Amentissement']”));

  • 我的页面上有一个下拉菜单。我测试量角器的目标是单击此下拉菜单中的一个选项,并让量角器检查结果: 我的量角器测试看起来像: 如果你想知道的话,ptor.ignoreSynchronization是启用的,因为我的网页不断地轮询后端的一些更新。 量角器在我运行测试时抛出以下错误: 我不明白这个错误是关于什么的。这个元素肯定是可见的,因为当我查看页面的源代码时,我可以在DOM结构中看到它。 善意的忠告

  • 问题内容: 在这里,我尝试使用Selenium脚本从下拉列表中选择一个值,但 在控制台中却收到此错误,例如 “线程“主”中的异常” org.openqa.selenium.support.ui.UnexpectedTagNameException:元素应 为“选择”但为“跨度”。 下拉菜单中有多个值,我需要在其中选择一个值。 问题答案: @MosheSlavin的分析和回答是正确的方向。 这个错误

  • 我正在努力尝试从以下下拉菜单中选择一个名为“某些产品”的产品。'id="s2id_autogen81"'是新的ID元素,我使用该ID来抓取项目,但它被更改为这个自动生成值,我不确定要使用量角器抓取什么。 从下拉菜单中选择它 从选择后的下拉列表中

  • 仍然是新的量角器,茉莉等。 今天,我正在尝试在我的一个测试中与下拉选项列表进行交互。 这是: var 选择下降 = 元素(按.css(“.下拉列表”);所有选项 = 元素(按选项(“某些选项”)); 现在点击下拉列表 selectDropDown.click(); 单击索引为 2 的下拉列表中的“选项” allOptions.get(2). Click(); 一些用于断言的代码。。。。 现在的问题

  • 问题内容: 我有一个GWT应用程序,正在尝试使用Selenium编写一些测试。 我正在使用XPath来标识测试页面上的元素。使用将无效,因为这些值是由GWT自动生成的,并且可以更改。当我意识到我可以按其标签找到按钮时,事情进展顺利,如下所示: 但是,当我开始运行多个测试时,我开始遇到问题。我意识到问题是,一旦Javascript生成的GWT应用程序的所有不同“页面”都保留在HTML中的隐藏元素中。