Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to come back from iframe to main page to work on main page elements - using selenium webdriver [closed]

I have used Driver.switchTo().frame("XXXXX"); to go to iframe on the main page

Now I want to go back to Main page to work with other operation using selenium webdriver

I had tried to get window handles

but I can't get iFrame window handle

like image 808
Jasmine.Olivra Avatar asked Jun 30 '12 05:06

Jasmine.Olivra


People also ask

How do I switch back from frame to main page?

To move back to the parent frame, you can either use switchTo(). parentFrame() or if you want to get back to the main (or most parent) frame, you can use switchTo(). defaultContent(); driver.

What method is used to switch to the main page from an iFrame?

Using switchTo().defaultContent() The switchTo(). defaultContent() method will switch focus to the first frame on the page. In the case of iFrames, the context is switched back to the main (or Parent) document.

How do I switch from main window to frame?

In order to access a frame element, the driver focus has to shift from the main browser window to the frame. To again focus back to the current page from frame, the method switchTo(). defaultContent() is used.

How do I switch between iFrames in Selenium?

Another way to switch between frames in selenium is to pass the WebElement to the switchTo() command. Here the primary step is to find the iframe element and then pass it to the switch method.


1 Answers

driver.switchTo().defaultContent();
like image 117
nilesh Avatar answered Oct 06 '22 00:10

nilesh