Failed: null value in entry: name=null error while

2019-07-07 17:06发布

I am trying to switch popup window of my AngularJS application. Following is my code:

    browser.ignoreSynchronization = true;
    browser.getAllWindowHandles().then(function (handles) {
        browser.switchTo().window(handles[1]);

    });

Getting following error:

Failed: null value in entry: name=null
Stack:
UnknownError: null value in entry: name=null

2条回答
该账号已被封号
2楼-- · 2019-07-07 17:38

You might be trying to switch to a new tab before it is actually opened - wait for the window handles count to be more than a desired count with a custom Expected Condition:

function windowCount(count) {
    return function () {
        return browser.getAllWindowHandles().then(function (handles) {
            return handles.length >= count;
        });
    };
};
browser.wait(windowCount(2), 10000);

browser.getAllWindowHandles().then(function (handles) {
    browser.switchTo().window(handles[1]);
});
查看更多
地球回转人心会变
3楼-- · 2019-07-07 17:38

In AngularJS application there is not handle for popup window ,we need to get model Id for popup and then need to identify elements on it

eg .

var alertPop = element(by.id('popId'))

expect(alertPop.isDisplayed()).toBeTruthy();

var element= alertPop.element(by.model('vm.message'));

查看更多
登录 后发表回答