Failed: null value in entry: name=null error while switching Popup window

梦想的初衷 提交于 2020-01-15 05:37:25

问题


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

回答1:


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]);
});



回答2:


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'));



来源:https://stackoverflow.com/questions/36477459/failed-null-value-in-entry-name-null-error-while-switching-popup-window

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