Angularjs   发布时间:2022-04-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了angularjs – 量角器等待isElementPresent并单击等待元素失败大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我的end2end测试有问题.有时他们通过没有任何问题,但三分之二的时间他们失败.我使用以下代码的量角器:
describe('Admin dashboard delete Exports',function () {
        it('create export',function () {
            browser.get(e2GUrl + '/admin/studies');
            ptor.wait(function() {
                return ptor.iSELER_30_11845@entPresent(by.id('export'));
            },5000,'wait for study list page to be loaded.');
            element(by.id('export')).click();
         });

HTML(请注意,此元素是可见的,不会被ng-if或ng-show隐藏):

<ul>
    <li data-ng-repeat="study in studies">
       <div data-ng-controller="ExportController" class="btn-group">
          <a id="export" class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#">
             <i class="fw-icon fw-icon-cloud-download"></i>Export
                <span class="caret"></span>
           </a>
           <ul class="dropdown-menu export-list">
                <li class="excel"><a data-ng-click="excel(study.CodE)">Export to Excel</a>
                </li>
           </ul>
       </div>
    </li>
</ul>

我收到错误

发现问题在于:
元素isPresent()和isDisplayed()

因此,如果您只等待isPresent(),它可以在html中找到但尚未显示.

如果你只是想使用elm.isDisplayed(),那么它将会崩溃,如果该元素尚不存在,它将会崩溃.所以你必须先检查isDisplayed()之前是isPresent()

我创建了一个等待阻塞2个属性函数

this.waitUntilReady = function (elm) {
        browser.wait(function () {
            return elm.isPresent();
        },10000);
        browser.wait(function () {
            return elm.isDisplayed();
        },10000);
    };

describe('Admin dashboard delete Exports',function () {
            browser.get(e2GUrl + '/admin/studies');
            waitUntilReady(element(by.id('export')));
            element(by.id('export')).click();
         });

大佬总结

以上是大佬教程为你收集整理的angularjs – 量角器等待isElementPresent并单击等待元素失败全部内容,希望文章能够帮你解决angularjs – 量角器等待isElementPresent并单击等待元素失败所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。