How to remove the Popup using WebDriver

282 views
Skip to first unread message

Subbarayulu Neela

unread,
Jan 6, 2016, 3:32:16 AM1/6/16
to seleniu...@googlegroups.com, webd...@googlegroups.com
Hi Team,
Whenever the firefox launching , getting "know your location" Popup unnecessarily.
Manually I clicked on allow. However from Selenium execution the popup exists automatically. Due to this reason all my tests are failed.

I am using WebDriver only. I have cleaned Browser Cache also.

Could you anyone suggest me to resolve the issue.
Please refer the attached screenshot.

--
     Your's
N.subbarayulu
IMG-20160106-WA0015.jpg

Tam Minh

unread,
Jan 6, 2016, 5:03:57 AM1/6/16
to Selenium Users, webd...@googlegroups.com
Hi Subbarayulu,

I don't know if it works for you or not, but I usually bypass
unnecessary popup by adding cookies. Hope it helps.

Tam

darrell

unread,
Jan 6, 2016, 9:24:38 AM1/6/16
to webdriver, seleniu...@googlegroups.com
Asking you for your location is a feature of Firefox and not of the website alone. So the prompt you are being sent is actually a feature of Firefox. This means you cannot have Selenium turn it off.

Selenium does have the ability to open Firefox with a specific profile. So you could run Firefox with the -P option, create a Selenium specific profile. Then edit the profile to turn off geo.enabled. Save the profile and use that profile when you start up Firefox. If you go to https://code.google.com/p/selenium/wiki/FirefoxDriverInternals it is a good starting point on how to use custom profiles. As for the change to disable geo location:

  1. Open Firefox
  2. Enter about:config in the address bar
  3. Find geo.enabled
  4. Double click the entry
You should now have geo.enabled set to false.

lkat...@tripodtech.net

unread,
Jan 7, 2016, 5:45:58 AM1/7/16
to webdriver, seleniu...@googlegroups.com

When the popup arises, you can switch the focus to popup and click on "Allow". Then you can continue with the rest of your flow. Try with below code :

// Handling Popup
webdriver.switchTo().window(findElement(By.xpath("//path to poup")));
webdriver.findElement(By.xpath("// path to 'Allow' button")).click();

// Now switch the focus to your Web-page
webdriver.switchTo().defaultContent();

After this, you can continue with your flow.

Reply all
Reply to author
Forward
0 new messages