【问题标题】:What is dropdown protractor code什么是下拉量角器代码
【发布时间】:2016-09-15 21:48:45
【问题描述】:

下拉菜单包含ng-model ="text.abc" 并包含可见的text="Test"

<md-select id="select_55" class="ng-pristine ng-untouched ng-valid ng-valid-required" required="" aria-label="queuingModel: SKILL_GROUP" ng-model="text.abc" md-on-close="vm.changeQueue(vm.queue.resourcePoolType)" name="resourcePoolType" tabindex="0" aria-disabled="false" role="listbox" aria-expanded="false" aria-multiselectable="false" aria-owns="select_container_56" aria-required="false" aria-invalid="false" style="">
<md-select-value id="select_value_label_51" class="md-select-value">
<span>
<div class="md-text ng-binding">SKILL_GROUP</div>
</span>
<span class="md-select-icon" aria-hidden="true"></span>
</md-select-value>

我无法使用此代码:

element(by.model('text.abc')).$('[value=" ?"]').click(); 

我没有下拉值。

在这种情况下,下拉的量角器代码应该是什么?

【问题讨论】:

    标签: javascript angularjs selenium protractor


    【解决方案1】:

    试试这个代码。

    // Select Category
    element.all(by.model('dropdown')).each(function (eachElement, index)
    {
         eachElement.click();
         browser.driver.sleep(500);
         element(by.model('text.abc')).click();
         browser.driver.sleep(500);
    });
    

    希望这会有所帮助。 :) 请参阅answers here 了解更多信息。

    【讨论】:

    • 我想点击下拉菜单的特定元素,例如测试不是针对每个元素,此代码不起作用
    • 好的。你能给我你的下拉列表的 HTML 代码吗?
    【解决方案2】:

    您可以通过文本选择一个值

    var optionToSelect = "SKILL_GROUP";
    
    var dropdown = element(by.model('text.abc'));
    dropdown.click();
    
    dropdown.element(by.xpath(".//div[contains(@class, 'md-text') and . = '" + optionToSelect + "']")).click();
    

    【讨论】:

    • 现在发生此错误失败:元素在点 (703, 415.5) 处不可点击。其他元素会收到点击:
    【解决方案3】:

    怎么样...

    element(by.id(dropdownList)).sendKeys("value");
    

    element(by.model(dropdownModel)).sendKeys("value");
    

    【讨论】:

    • 我不明白这个。When(/^I select string "([^"]*)" from the dropdown menu with id "([^"]*)"$/, function( string, dropdownList, next) 语句你能详细说明一下吗
    • 道歉。我习惯于使用Cucumberjs 来定义我的测试。我已经更新了我的答案以删除对黄瓜的引用
    猜你喜欢
    • 2015-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-28
    • 2015-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多