Protractor Button Click and open page in new tab

后端 未结 5 814
我在风中等你
我在风中等你 2021-02-08 02:21

I am fairly new to Protractor. I am trying to automate a scenario where I click on a button and its opens up a page in new tab and then we need to populate form in new page and

5条回答
  •  渐次进展
    2021-02-08 03:07

    You need to wait until the page opens by using callbacks. Try something in this sense:

        element(by.id("newPlan")).click().then(function () {
            browser.getAllWindowHandles().then(function (handles) {
                newWindowHandle = handles[1]; // this is your new window
                browser.switchTo().window(newWindowHandle).then(function () {
                    // fill in the form here
                    expect(browser.getCurrentUrl()).toMatch(/\/url/);
                });
            });
        });
    

提交回复
热议问题