问题
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