Protractor button click and open page in new tab


Sumitomo

I am new to protractor. I'm trying to automate a scenario where I click a button and it opens a page in a new tab and then we need to populate the form in the new page and submit it.

Problem : When I click the button to open a new page. My tests don't wait for the new page to load and say test done and success message.

I am using the button's simple click event to click the button.

element(by.id(“ newPlan”))。click()

Am I missing something? Do I need to do something so that the test waits for the new page to load and then executes some function?

Michal Lison

You need to wait until the page is opened with the callback. Try doing it this way:

    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/);
            });
        });
    });

Related


Protractor button click and open page in new tab

Sumitomo I am new to protractor. I'm trying to automate a scenario where I click a button and it opens a page in a new tab and then we need to populate the form in the new page and submit it. Problem : When I click the button to open a new page. My tests don't

Protractor button click and open page in new tab

Sumitomo I am new to protractor. I'm trying to automate a scenario where I click a button and it opens a page in a new tab and then we need to populate the form in the new page and submit it. Problem : When I click the button to open a new page. My tests don't

Protractor button click and open page in new tab

Sumitomo I am new to protractor. I'm trying to automate a scenario where I click a button and it opens a page in a new tab and then we need to populate the form in the new page and submit it. Problem : When I click the button to open a new page. My tests don't

Protractor button click and open page in new tab

Sumitomo I am new to protractor. I'm trying to automate a scenario where I click a button and it opens a page in a new tab and then we need to populate the form in the new page and submit it. Problem : When I click the button to open a new page. My tests don't

Click Primefaces in a new tab on the button to open the page

username i have this <h:outputLink value="http://.....index.html" target="_blank">open</h:outputLink> But it shows up as a link. How to create a similar button? I need the "Open" button. When I press this button I need to open the link in a new tab in the bro

Click Primefaces in a new tab on the button to open the page

username i have this <h:outputLink value="http://.....index.html" target="_blank">open</h:outputLink> But it shows up as a link. How to create a similar button? I need the "Open" button. When I press this button I need to open the link in a new tab in the bro

Click Primefaces in a new tab on the button to open the page

username i have this <h:outputLink value="http://.....index.html" target="_blank">open</h:outputLink> But it shows up as a link. How to create a similar button? I need the "Open" button. When I press this button I need to open the link in a new tab in the bro

Click Primefaces in a new tab on the button to open the page

username i have this <h:outputLink value="http://.....index.html" target="_blank">open</h:outputLink> But it shows up as a link. How to create a similar button? I need the "Open" button. When I press this button I need to open the link in a new tab in the bro

Click Primefaces in a new tab on the button to open the page

username i have this <h:outputLink value="http://.....index.html" target="_blank">open</h:outputLink> But it shows up as a link. How to create a similar button? I need the "Open" button. When I press this button I need to open the link in a new tab in the bro

Click Primefaces in a new tab on the button to open the page

username i have this <h:outputLink value="http://.....index.html" target="_blank">open</h:outputLink> But it shows up as a link. How to create a similar button? I need the "Open" button. When I press this button I need to open the link in a new tab in the bro

Click the button to open a new tab

Nathan Wilson I want to create a link with a button that opens in a new tab. The code I'm currently using is currently opening a blank tab and I'm not sure why. <div class="text text-left"> <h2>WORK</h2> <h1>Title</h1> <p>Lorem ipsum dolor sit am

Click the button to open a new tab

Nathan Wilson I want to create a link with a button that opens in a new tab. The code I'm currently using is currently opening a blank tab and I'm not sure why. <div class="text text-left"> <h2>WORK</h2> <h1>Title</h1> <p>Lorem ipsum dolor sit am

Open a new tab after button click in AngularJS

Neptune: <button type="button" class="btn btn-primary" ng-click="openTab()">new tab</button> openTab = function () { $http.post('www.google.com'); } What I want is to post a requirement and then open the response html in a new tab when the "openTab" button

Open a new tab after button click in AngularJS

Neptune: <button type="button" class="btn btn-primary" ng-click="openTab()">new tab</button> openTab = function () { $http.post('www.google.com'); } What I want is to post a requirement and then open the response html in a new tab when the "openTab" button

Open new tab on button click using JQUERY

Rajan My scene is like this: I have edit user module. Each user is assigned a base INI file . When we edit a user, we have a drop down menu from which to select his base INI file. After selection, we can save the user. And the ID of the selected file is also s

Open new tab on button click using JQUERY

Rajan My scheme is this: I have edit user module. Each user is assigned a base INI file . When we edit a user, we have a drop down menu from which to select his base INI file. After selection, we can save the user. And the ID of the selected file is also saved

Open a new tab after button click in AngularJS

Neptune: <button type="button" class="btn btn-primary" ng-click="openTab()">new tab</button> openTab = function () { $http.post('www.google.com'); } What I want is to post a requirement and then open the response html in a new tab when the "openTab" button

Open new tab on button click using JQUERY

Rajan My scheme is this: I have edit user module. Each user is assigned a base INI file . When we edit a user, we have a drop down menu from which to select his base INI file. After selection, we can save the user. And the ID of the selected file is also saved

Click on the image to open a new tab in the HTML page

Gillan click on image to open new tab in html page how to add clickable image to open new tab in html page? Jeffrey Try this https://www.w3schools.com/jsref/met_win_open.asp <!DOCTYPE html> <html> <body> <p>Click the button to open multiple windows.</p> <a h

How to: Click to open new page in new tab and redirect old page

Tyron Piscule Been trying to find a solution but I can't. I need to click a button to trigger two events. This code works in firefox but not in Chrome: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width">

How to: Click to open new page in new tab and redirect old page

Tyron Piscule Been trying to find a solution but I can't. I need to click a button to trigger two events. This code works in firefox but not in Chrome: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width">

How to: Click to open new page in new tab and redirect old page

Tyron Piscule Been trying to find a solution but I can't. I need to click a button to trigger two events. This code works in firefox but not in Chrome: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width">

How to: Click to open new page in new tab and redirect old page

Tyron Piscule Been trying to find a solution but I can't. I need to click a button to trigger two events. This code works in firefox but not in Chrome: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width">

How to: Click to open new page in new tab and redirect old page

Tyron Piscule Been trying to find a solution but I can't. I need to click a button to trigger two events. This code works in firefox but not in Chrome: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width">

How to: Click to open new page in new tab and redirect old page

Tyron Piscule Been trying to find a solution but I can't. I need to click a button to trigger two events. This code works in firefox but not in Chrome: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width">

How to: Click to open new page in new tab and redirect old page

Tyron Piscule Been trying to find a solution but I can't. I need to click a button to trigger two events. This code works in firefox but not in Chrome: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width">

How to: Click to open new page in new tab and redirect old page

Tyron Piscule Been trying to find a solution but I can't. I need to click a button to trigger two events. This code works in firefox but not in Chrome: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width">

How to: Click to open new page in new tab and redirect old page

Tyron Piscule Been trying to find a solution but I can't. I need to click a button to trigger two events. This code works in firefox but not in Chrome: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width">

How to: Click to open new page in new tab and redirect old page

Tyron Piscule Been trying to find a solution but I can't. I need to click a button to trigger two events. This code works in firefox but not in Chrome: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width">