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 in Selenium by Surya
• 970 points
276 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 by Vaishnavi
• 1,160 points

Related Questions In Selenium

0 votes
1 answer

How to get the text from a website using selenium?

hey, you can use get.text() method to ...READ MORE

answered Dec 31, 2018 in Selenium by Sudhanshu
1,987 views
0 votes
1 answer

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

Its pretty simple. Check out the below ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,110 points
8,537 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,110 points
1,007 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
1,153 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
892 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 in Selenium by Vaishnavi
• 1,160 points

edited May 10 by Omkar 1,232 views
0 votes
1 answer