Sumit Sumit - 1 year ago 540
AngularJS Question

Protractor Button Click and open page in new tab

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 submit.

Issue: when i click on button to open new page. My tests does not wait for new page to load and say test completed and success message.

I am using simple click event of that button to click the button.


Am I missing something ? Do i need to do something so that my tests wait for new page to load and then I can perform some functions ?

Answer Source

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

    element("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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download