Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (29.3k points)

Using Selenium WebDriver with JAVA. I am trying to automate a functionality where I have to open a new tab do some operations there and come back to the previous tab (Parent). I used switch handle but it's not working. And one strange thing the two tabs are having same window handle due to which I am not able to switch between tabs.

However when I am trying with different Firefox windows it works, but for tab, it's not working.

Please help me how can I switch tabs. OR how can I switch tabs without using window handle as window handle is the same as both tabs in my case?

(I have observed that when you open different tabs in the same window, window handle remains same)

1 Answer

0 votes
by (50.2k points)

Check this code it will help you switch your driver to a new tab before you want to do something on a new tab.


    ArrayList<String> tabs2 = new ArrayList<String> (driver.getWindowHandles());




The above code will enable you to switch driver to a new tab.

Browse Categories