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
5,863 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 6, 2020 in Selenium by Sri
• 3,190 points
25,687 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 6, 2020 in Selenium by Sri
• 3,190 points
18,913 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,500 points
13,676 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,190 points
9,143 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,910 points
7,221 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 3, 2020 in Selenium by Sri
• 3,190 points
7,875 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 13,714 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
4,794 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP