1

i'm new to selenium so i don't know weather to ask this question or not please correct me if im wrong ..

i have a site where clicking a button opens the link in a new tab i have succefull used the selenium windowhandle and done the work on the new open tab but when switching to the parent tab i have a problem that is the code is being executed in that parent tab but the tab is not being focused so i can't see how my code is being executed in parent window for that i know to press Crlt +1 using java robot but is there any other way of haveing the focus back to my parent window so that i can see what is happening...

Thanks in Advance

5
  • Refer this link Going Back to parent window in web driver Commented Dec 11, 2012 at 7:09
  • hi thanks for the reply but this doc says of closing the opened tab.. i dont want to close it because ill be shifting back to that tab after filling a form in the parent window... Commented Dec 11, 2012 at 8:41
  • Easy then remove that line..:) Commented Dec 11, 2012 at 8:48
  • thanks for the reply acutally im still having that same focusing problem like the driver moved to the parent tab yet what im viewing is the newTab that is opened what i want to see the parent window how my testing code is being done in it .. i hope u understood .. Thank you Commented Dec 11, 2012 at 11:08
  • Sorry to say but if you will not close the window opened over the parent window(As you said : "thanks for the reply but this doc says of closing the opened tab.. i dont want to close")..The same window will be visible to you..But no issue all your command will run on the parent window only and later on you can switch to this window as well. Commented Dec 11, 2012 at 11:27

2 Answers 2

3

This is what I use:

webDriver.switchTo().window(webDriver.getWindowHandles().toArray()[0]) 
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Yishaib for the Reply .. my problem is like how u move the focus on the parent window so that the parent window comes fornt while the new open tab goes back ... can u help me on this ..
OK, now I understand what you mean. Webdriver switches focus but the 'parent' tab doesn't become visible. I couldn't find a way to change the visible tab. My suggestion to you is to close the second tab before you switch focus the the first one. webdriver.close()
hi Yishaib thank you for the comment once again, but the thing is i don't want to close my tab because i have to come to the new tab once again ....
1

To bring the window to front of all the windows I think you can try this.

webdriver .manage().window().maximize(); 

2 Comments

hi Harsha thanks ur idea really nice i use the Dimension and getposition in the manage window to minimize my opentab ... Thank you very much
hi yes, the maximize() and the driver.manage().window().setSize(new Dimension(x,y)); also some time does the trick ...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.