Pages

Sunday 26 February 2012

How can I switch WebDriver control between Frames?

If the application under test contains frames, then we need to switch the WebDriver control to that frame before interacting with the element inside the frame.


We can switch to frame either with it’s name/id or by specifying frame index.


Sample code : By using frame name


driver.switchTo().frame("frameName");

By index (Zero-based):


driver.switchTo().frame(1);

And to come back to default frame:

driver.switchTo().defaultContent();

No comments:

Post a Comment