RE: Selenium Web Driver : How to transfer control to the new tab that opens on top of existing/current tab

Hello Masters,
I am new to selenium automation and this is my first question to the forum. I am currently automating a web application, basically starting with the the home page that has several links at top/ribbon to navigate to different pages. Where in one of the link navigates to web outlook, on click of this link it reloads as a tab on top of current tab(home page) within same browser window.

Currently my automation script failing when it clicks on the link that opens the web outlook page. The point to Note is “the browser tab is opening on top of current tab”, the automation run fails as its not able to locate element on the reloaded tab

I am not exactly sure, but I feel the control is not getting transferred to the reloaded tab.
I am also confused why would it need to transfer control as it still in the same browser window

some more info:
I am testing in IE browser, selenium web driver, using java, I have not tried windows handle/ switch as I don’t know how to use them.

please suggest with code…
Appreciate quick help/ solution on this problem.

Add Comment
2 Answers

List<String> wHandle = new ArrayList<String> (driver.getWindowHandles());
Set<String> wHandleSize = driver.getWindowHandles();
if (wHandleSize.size()>1) {
driver.switchTo().window(wHandle.get(1));“Switching to newly opened window”);
else“No new tab is opened”);

Supporter Answered on November 23, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.