Unable to switch back to default frame

0 votes
I am working on the following scenario.

I have a main web page in which there is an element which opens a dialog box. It is an IFrame and when i use diver.switchTo().frame(1); to access the new popup, i can access that frame. And I'm also able to perform the required activites in that same frame. And when I click on the "OK" button in that frame, the frame gets closed. Once this frame is closed, i'm not able to access any of the elements in my main page. I used the these switch back function calls to go back to the main page:
driver.switchTo().defaultContent() and driver.switchTo().frame(0). Since the frame gets closed i also tried without any switchTo() statements. But none of them gives me control of the main page.

Can somebody suggest solutions for it? Thanks in advance!
Mar 29, 2018 in Selenium by Shubham
• 12,270 points
45 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

That's because you should switch back to the original window by saving the window handle in an object. Check the below code:

String windowHandle = driver.getWindowHandle(); // save the original window handle

driver.switchTo().window(windowHandle); // handle the pop up
answered Mar 29, 2018 by nsv999
• 5,030 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

Need to switch between frames in Selenium

For switching between frames, use driver.switchTo().frame(). First ...READ MORE

answered Apr 6, 2018 in Selenium by nsv999
• 5,030 points
414 views
0 votes
1 answer

Unable to use Selenium IDE & Firebug on Firefox

Unfortunately, Selenium IDE will not work anymore ...READ MORE

answered Apr 9, 2018 in Selenium by nsv999
• 5,030 points
59 views
+1 vote
1 answer

Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.

This issue generally happens due to incompatibility ...READ MORE

answered May 31, 2018 in Selenium by bits1
• 120 points
1,713 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,030 points
76 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
448 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
56 views
0 votes
1 answer

Unable to connect to chromedriver 127.0.0.1:9515 on Amazon Linux AMI server

The issue seems to be only with ...READ MORE

answered Mar 26, 2018 in Selenium by nsv999
• 5,030 points
430 views
0 votes
2 answers

Unable to Click on an Element in Selenium (Python) even after finding it.

Here, I give you working script which ...READ MORE

answered Sep 19, 2018 in Selenium by Priyaj
• 56,120 points
4,578 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.