How to switch the access from the main window to the popup window using Selenium

0 votes

I am not able to switch the WebDriver control to the popup window, only the button popup gets opened.

I've tried using the getWindowHandles() but it only returns the window handle of the main window. 

I also tried using this command switchTo.window("window name") but it didn't work.

Please help me with this issue

May 24, 2019 in Selenium by Surya
• 970 points
3,007 views

1 answer to this question.

0 votes
Generally, the Modular Windows are part of the same DOM, unlike javascript alerts. The only thing that sets them apart from the other parts of the page is that they are in a different frame.

Check if this Modular Window lies inside a frame or an iframe tag. If any parent is a frame or an iframe then you will have to change the context to that particular frame before you can perform any action on the Modular Window.

So, first, find the frame and switch the access to it, driver.switchTo().frame() and then perform the action on the element you want to. Once this action is done, which would most probably navigate you back to the main page. Use this driver.switchTo().defaultPage() to bring focus back to main page.

Hope this helps:)
answered May 28, 2019 by Vaishnavi
• 1,180 points

Related Questions In Selenium

+1 vote
1 answer
0 votes
2 answers

How to get the text from a website using selenium?

driver.findElement(By.cssSelector("p")).getText() or  IWebElement element = Browser.GetElementByCssSelector("div.loginbox p"); string text = ...READ MORE

answered Sep 5, 2020 in Selenium by Sri
• 3,010 points
15,376 views
0 votes
0 answers
0 votes
2 answers

How to scroll the Page up or down in Selenium WebDriver? (using java)

JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript("window.scrollBy(0,555)", ""); or Action classes ...READ MORE

answered Sep 5, 2020 in Selenium by Sri
• 3,010 points
14,977 views
0 votes
2 answers

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,520 points
5,110 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,010 points
5,841 views
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,890 points
3,602 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2, 2020 in Selenium by Sri
• 3,010 points
4,345 views
0 votes
1 answer

How to auto-refresh the ChromeDriver using Selenium Webdriver?

You can use this command. Also, refresh ...READ MORE

answered May 10, 2019 in Selenium by Vaishnavi
• 1,180 points

edited May 10, 2019 by Omkar 8,250 views
0 votes
1 answer

How to save the content on the page (full page) using Selenium WebDriver?

Selenium isn't designed to do this, you ...READ MORE

answered Jun 28, 2019 in Selenium by Vaishnavi
• 1,180 points
1,082 views