Non-angular page opened after a click

后端 未结 2 1840
借酒劲吻你
借酒劲吻你 2020-11-28 14:50

I\'m trying to implement the following test scenario:

  • perform a click on a logo on the page
  • assert there is a new browser window opened (tab in Chrom
相关标签:
2条回答
  • 2020-11-28 15:31

    You can set ignoreSynchronization to be false once your verification is done. However, note that ignoreSynchronization is synchronous while everything else (click/get/etc) is asynchronous, so you need to be careful with that. Probably the safest way is to set it to true in beforeEach and false in afterEach, and just test that single logo click in that test.

    0 讨论(0)
  • 2020-11-28 15:43

    Another solution: I have used sleep since getWindowHandles was returning only one window name(parent/angular window). Let me know if there is a better way.

    this.validateProductPageInfo = function (productTitle) {
        browser.sleep(5000);
        browser.getAllWindowHandles().then(function (handles) {
            if (handles.length === 2) {
                browser.switchTo().window(handles[1]).then(function () {
                    var prodTitle = by.xpath('//h1[@id="fw-pagetitle"]');
                    browser.driver.findElement(prodTitle).getText().then(function (text) {
                        expect(text).toBe(productTitle);
                    });
                });
                browser.switchTo().window(handles[0]);
            } else {
                console.log("Error in switching to non angular window");
            }
        });
    };
    
    0 讨论(0)
提交回复
热议问题