不稳定打开新页面量角器非角度站点

时间:2022-12-07 01:23:23

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?

我该怎么办呢?

1 个解决方案

#1


0  

UnknownError: null value in entry: name=null

UnknownError:条目中的null值: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]);
});

#1


0  

UnknownError: null value in entry: name=null

UnknownError:条目中的null值: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]);
});