Pages

Wednesday, May 30, 2012

Switch to window - smart way

Selenium : Smart way to switch to new window



var handlesBefore = webDriver.WindowHandles; 
webDriver.Click(foo); //Which opens a new window 
var handlesAfter = webDriver.WindowHandles; 
var newHandle = handlesAfter.Except(handlesBefore).Single(); 
webDriver.SwitchTo().Window(newHandle); 


Switch to a window with known name 

No comments: