How to handle modal-dialog box in Protractor?

不问归期 提交于 2019-12-04 19:16:18

I've experienced a similar issue while testing an internal application when a popup was being opened with an animation effect (I think it is a culprit here) which had me think about waiting for an element inside the popup to become visible.

visibilityOf expected condition works for me in this case:

var email = element(by.css('.container.login.ng-scope #email'));
browser.wait(EC.visibilityOf(email), 5000);

email.sendKeys('test');

where EC is something I usually define globally in the onPrepare():

onPrepare: function () {
    ...

    global.EC = protractor.ExpectedConditions;
},

Just a side note, I think the locator could be improved here:

  • ng-scope is not something I would rely on
  • there is a model defined on the email field, how about:

    element(by.model('email'));
    

FYI, the complete spec I've executed:

"use strict";

describe("gifteng test", function () {
    var scope = {};

    beforeEach(function () {
        browser.get("http://www.gifteng.com/?login");
        browser.waitForAngular();
    });

    describe("Logging in", function () {
        it("should send keys to email", function () {
            var email = element(by.css('.container.login.ng-scope #email'));
            browser.wait(EC.visibilityOf(email), 5000);

            email.sendKeys('test');
        });

    });
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!