Please provide sample code for switchTo.window()

19 views
Skip to first unread message

Roopesh Soni

unread,
Jun 22, 2011, 8:35:57 AM6/22/11
to webdriver
Hi,
I am tring to use switchTo().window(). But i am not able to do it.
Could any one provide some sample code?

Luke Inman-Semerau

unread,
Jun 23, 2011, 12:02:46 PM6/23/11
to webd...@googlegroups.com
This will switch to another (arbitrary) window that is open:

String currentHandle = driver.getWindowHandle();
Set<String> handles = driver.getWindowHandles();
handles.remove(currentHandle);
if (handles.size() > 0)
driver.switchTo().window(handles.iterator().next());


--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.


Reply all
Reply to author
Forward
0 new messages