[英]Instability opening new page Protractor non angular site
I have a problem when I click in non angular site and the test opens a new non angular site tab. 单击非角度站点并且测试打开一个新的非角度站点选项卡时出现问题。 Sometimes works (a lot of times), but sometimes shows the following error:
有时可以工作(很多次),但是有时会显示以下错误:
Unknown Error: null value in entry: name=null
未知错误:条目中的空值:name = null
This is the code: 这是代码:
browser.ignoreSynchronization = true;
element(by.id('go')).click().then(function () {
browser.driver.getAllWindowHandles().then(function (handles) {
browser.driver.switchTo().window(handles[1]).then(function () {
browser.wait(EC.visibilityOf(element(by.id('text'))), 15000);
expect(element(by.id('text')).getText()).toEqual('Works');
expect(element(by.css('#crumbsNav .last')).getText()).toEqual('Payment');
});
browser.driver.close();
browser.driver.switchTo().window(handles[0]);
});
How I can fix it? 我该如何解决?
UnknownError: null value in entry: name=null
UnknownError:条目中的空值:name = null
Means you are trying to switch to a window that is not opened at the moment. 表示您正在尝试切换到当前未打开的窗口。 you should wait for the number of tabs to be more than 1 and only then switch.
您应该等待选项卡数量大于1,然后再切换。
So: 所以:
browser.ignoreSynchronization = true;
element(by.id('go')).click().then(function () {
browser.driver.getAllWindowHandles().then(function (handles) {
browser.wait(function(){return handles.size() > 1}, 15000);//MY ADDITION
browser.driver.switchTo().window(handles[1]).then(function () {
browser.wait(EC.visibilityOf(element(by.id('text'))), 15000);
expect(element(by.id('text')).getText()).toEqual('Works');
expect(element(by.css('#crumbsNav .last')).getText()).toEqual('Payment');
});
browser.driver.close();
browser.driver.switchTo().window(handles[0]);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.