如何切换到新的弹出窗口(非Angular应用程序)来运行Protractor?

时间:2014-09-16 15:53:03

标签: popup webdriver protractor

我正在尝试检查新弹出窗口的URL,此窗口来自非Angular应用程序。我尝试了我在Github的Protractor问题板上找到的代码。但是有一个错误:

Message:
   UnknownError: null value in entry: name=null
Stacktrace:
   UnknownError: null value in entry: name=null

这是我的剧本:

var handlePromise;
browser.ignoreSynchronization = true;
var landingPage=require("../page-objects/landing_page.js");
var ptor = protractor.getInstance();

describe('iso1 -', function() {
    landingPage.visitISO1();
    it('Administration should not be on the menu"', function() {
        expect(element(by.xpath('//*[@id="menu"]/ul[1]/li[3]/a')).isDisplayed()).toBe(true);   
        element(by.xpath('//*[@id="menu"]/ul[1]/li[3]/a')).click();  

        handlePromise = browser.driver.getAllWindowHandles();
            var handles = handlePromise.then(function (handles) {
//                parentHandle = handles[0];
                popUpHandle = handles[1];
                handle = browser.switchTo().window(popUpHandle);
//                ptor.sleep(1000);
                handle = browser.getWindowHandle();
                expect(handle).toEqual(popUpHandle);
//              browser.driver.executeScript('window.focus();');

                var expectedUrl = browser.driver.getCurrentUrl();
                expect(expectedUrl).toEqual('https://XXXXXXXXXXXXXXXXXXXXXXXXXXXX');
            });
        landingPage.menu.home();
    });
});

非常感谢提前。

0 个答案:

没有答案