New Tab Handling | Bondar Academy
Course: Mastering testRigor
Module: Interation with Web Elements
Instructor: Artem Bondar
Lesson Summary
In this lesson, we explore how to automate multiple browser tabs using Test Trigger and how to switch between them effectively. Key Steps in Automation Navigate to the window page of the test application. Click the button labeled open home page in a new tab . Upon clicking this button, a new tab opens in the browser. Test Trigger automatically switches to this new tab, mimicking standard browser behavior. Creating the Test Create a new test in Test Trigger. Use the command click button open home page to automate the button click. After running the test, you can validate that the new tab has opened successfully and contains the expected content, such as the text temperature . Switching Between Tabs To switch back to the initial tab, use the command: switch to tab 1 After switching, you can make further assertions to ensure the correct content is displayed. Closing Tabs If you wish to close a tab, navigate to it and use the command: close tab This will close the current tab, leaving only the desired tab open. Summary Test Trigger automatically navigates to new tabs opened by button clicks. Use switch to tab to change tabs and close tab to remove unnecessary tabs. That's it for this lesson! See you in the next one.
Video Transcript
In this lesson we will talk about how to automate multiple browser tabs using Test Trigger and how to switch between the tabs of the browser. So let's get into it. On our test application we need to click on model and overlays and window page. And here we have a button open home page in a new tab. So if I click on this button our test application opens in the new tab of the browser. And now we have two tabs opened. So let's automate this scenario clicking on this button and then navigating between the tabs. So how to do this in Test Trigger. And I create a new test. And first of all we need to navigate to the window page. So it's model and overlays and then click window. All right so we need to click on this button open home page in a new tab. And we can provide just a partial value open home page since this text is unique for this particular page. So I type click button open home page. And let's quickly run this test to see what's going to happen. All right test completed. And let's check the screenshots. So this is the window page. We successfully clicked on the open home page button. And then a new home page was opened. And as you can see the tab was opened even if it is a new tab. So this is how Test Trigger works. If the click on this button open home page the tab was opened even if it is a new tab. So this is how Test Trigger works. If the click on the button resulting in opening of the new tab Test Trigger automatically switch to this tab. The same way how it's handled in the browser. We click on the button and it opens a new page. So now let's make a quick assertion and then switch back to our initial tab which is this one. So quick edit and I make a quick assertion that check that page contains for example we want to validate this one this text temperature. Because this text exists only on the home page. And now I would like to switch back to the initial tab. How to do this? So the command will be switch to tab and provide the number of the tab where you want to switch. In our example it will be tab number one. Okay and let's make assertion by the way one more time that after we made a switch check that page contains open home page. This is the text that exists on our button and let's run this tab. All right test passed successfully. Let's check it out. Click on the home page. The next screen is the home page and we made a validation of the temperature. And then we made a switch to initial tab and validated that open home page in the tab. So looks fine and now let's say that we don't need this tab anymore. So at the end of this test we switched back to this page. But if we would like to close this tab I do like this. We would be navigated back to the home page. The second tab which is currently opened in the browser. So you can do this in test trigger as well. So all you need to do is to provide the prompt close tab. That's it. And after this operation we expect the tab where window page is opened will be closed. And this will result that only the second tab will remain open which has the home page open. So we will validate the temperature is displayed on the home page. And let's run this test one more time. All right test passed successfully. So we'll check it out. So we click on the button. The new tab opened. We validated we are on temperature page. Then we switched to the tab one. Open home page in new tab. We're closing this tab and we are back to the tab that is remained open. All right that's it. Let's quickly summarize what we did in this lesson. So when you click on the buttons which opens a new tab in the browser test trigger will navigate to this tab automatically. If you want to switch between the tabs you need to use the prompt switch to tab and provide the number of the tab that you want to switch to. If you need to close not needed tab just navigate to this tab and use the prompt close tab. All right that's it guys and see you in the next lesson.