Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to navigate back to current page from Frame in selenium webdriver

How to navigate back to main page from an iframe?

Example:

driver.SwitchTo.Frame(1);

driver.SwitchTo().DefaultContent();

Is not working. Can anyone suggest any other way to retain control?

like image 641
curiousDev Avatar asked Jul 25 '13 11:07

curiousDev


2 Answers

This is the way recommended at seleniumeasy Working with frames

driver.switchTo().defaultContent();
like image 72
KnuturO Avatar answered Nov 11 '22 15:11

KnuturO


You could always directly switch back to the window using:

driver.SwitchTo().Window(driver.WindowHandles[0]);
like image 34
Nathan Dace Avatar answered Nov 11 '22 15:11

Nathan Dace