Automation 量角器-选择下拉菜单时元素不可见。(但手动选择时可见)

Automation 量角器-选择下拉菜单时元素不可见。(但手动选择时可见),automation,protractor,angularjs-e2e,Automation,Protractor,Angularjs E2e,我已经搜索了2天了,但我找不到解决方案,我想选择一个下拉列表。当我使用某个element.all css定位器单击下拉列表时,它会单击下拉列表(下拉列表打开,但显示错误)。因此,我尝试使用linkText打开下拉列表(完全打开)。但此后,我无法在下拉列表中选择该选项。(显示的元素不可见)。此外,我无法通过链接文本选择该选项。详情如下: <div class="collapse navbar-collapse"> <ul class="nav navbar-nav navbar-

我已经搜索了2天了,但我找不到解决方案,我想选择一个下拉列表。当我使用某个element.all css定位器单击下拉列表时,它会单击下拉列表(下拉列表打开,但显示错误)。因此,我尝试使用linkText打开下拉列表(完全打开)。但此后,我无法在下拉列表中选择该选项。(显示的元素不可见)。此外,我无法通过链接文本选择该选项。详情如下:

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

  • 房客
我试着通过下面的方法来选择,但我不能让它工作

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

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

    this.clickDropChoice = function(dropdown, optionChoice) {
        dropdown.element(by.cssContainingText('option', optionChoice)).click()
    };
    

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

    this.clickDropChoice = function(dropdown, optionChoice) {
        dropdown.element(by.cssContainingText('option', optionChoice)).click()
    };
    


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

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

    ReferenceError:未定义属性。wats用于在前面添加属性。我还需要做什么吗。Common.Tenant.click();浏览器。睡眠(4000);元素(by.cssContainingText('div.dropdown','cust2')。单击();浏览器。睡眠(4000);我的同位语,来自一个助手文件,我忘了提到我使用的参数。。。基本上,在我的代码中的任何地方,我都想点击一个下拉列表,我只调用这个helper文件函数:)我对它进行了编辑,以包含适当的参数,并试图更清楚地标记它们:)hi@TesterHi我需要用元素传递下拉参数吗??。你能解释清楚一点吗。sorrydropdown是您的下拉菜单标识符,optionChoice是您要选择的选项。identifer是下拉列表的id:element(by.id('simple-dropdown');optionchoice是您要单击的选项选项中显示的文本。很抱歉,请再次查看下面的代码。这是我做过的,但测试通过了,但没有选择下拉列表。”var测试=元素(按.id('simple-dropdown');this.clickDropChoice=函数(test,cust2){dropdown.element(by.cssContainingText('option',cust2)).click()};'@我做错什么了吗。仅供参考clickDropChoice似乎未使用。ReferenceError:未定义属性。wats用于在前面添加属性。我还需要做什么吗。Common.Tenant.click();浏览器。睡眠(4000);元素(by.cssContainingText('div.dropdown','cust2')。单击();浏览器。睡眠(4000);我的同位语,来自一个助手文件,我忘了提到我使用的参数。。。基本上,在我的代码中的任何地方,我都想点击一个下拉列表,我只调用这个helper文件函数:)我对它进行了编辑,以包含适当的参数,并试图更清楚地标记它们:)hi@TesterHi我需要用元素传递下拉参数吗??。你能解释清楚一点吗。sorrydropdown是您的下拉菜单标识符,optionChoice是您要选择的选项。identifer是下拉列表的id:element(by.id('simple-dropdown');optionchoice是您要单击的选项选项中显示的文本。很抱歉,请再次查看下面的代码。这是我做过的,但测试通过了,但没有选择下拉列表。”var测试=元素(按.id('simple-dropdown');this.clickDropChoice=函数(test,cust2){dropdown.element(by.cssContainingText('option',cust2)).click()};'@我做错什么了吗。仅供参考,clickDropChoice似乎未被使用。甚至可以通过查找子元素来尝试。var el=element(by.binding('selectedTenant.ParentOwnerName')).element(by.css('a[ng click=“selectTenant(2)”));el.click();您是否尝试单击
    锚定
    元素而不是
    列表
    元素?此外,如果字母表无法通过
    sendKeys()
    函数以任何方式识别,则可以传递字母表。谢天谢地,我只有2-3个月大。如果我错了,请纠正我。这是通过.css('[ng]单击)到达tel的锚元素ur吗‌​=“选择租户(2)”]”)。如果是的话,我试过这个。是的,我也试过sendkeys。我不知道如何通过字母表。请更准确地解释,增加了两行。我想我们必须首先将它切换到div,然后我们需要单击下拉元素来工作。如果我的猜测是正确的,我能告诉我怎么做。你的网站是公共领域的,我们可以访问它吗?我不知道你为什么不能点击下拉列表,但是stackoverflow中有很多答案,说明了如何从下拉列表中选择一个值。他们都不工作?这里有一些——或者更多。如果他们都不工作,请告诉我。通过查找子元素来尝试。var el=element(by.binding('selectedTenant.ParentOwnerName')).element(by.css('a[ng click=“selectTenant(2)”));el.click();您是否尝试单击
    锚定
    元素而不是
    列表
    元素?此外,如果字母表无法通过
    sendKeys()
    函数以任何方式识别,则可以传递字母表。Th