-1

Example of what I want to click

Several
  • 5
  • 3
  • Does this answer your question? [How to allow Location and Notifications in Chrome incognito mode in Python Selenium?](https://stackoverflow.com/questions/64062890/how-to-allow-location-and-notifications-in-chrome-incognito-mode-in-python-selen) – DeadSec Mar 15 '21 at 15:12
  • Forgot to add, I am using FireFox – Several Mar 15 '21 at 17:00
  • https://stackoverflow.com/questions/3859935/webdriver-click-share-location-button-in-firefox – DeadSec Mar 15 '21 at 17:06

1 Answers1

0

you cannot click it , allow the geo location in firefox instead using firefox option:

example snippet:

<!DOCTYPE html>
<html>
<body>

<p>Click the button to get your coordinates.</p>

<button onclick="getLocation()">Try It</button>

<p id="demo"></p>

<script>
var x = document.getElementById("demo");

function getLocation() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(showPosition);
  } else { 
    x.innerHTML = "Geolocation is not supported by this browser.";
  }
}

function showPosition(position) {
  x.innerHTML = "Latitude: " + position.coords.latitude + 
  "<br>Longitude: " + position.coords.longitude;
}
</script>

</body>
</html>

copy and save it as an html file and open it in script:

Selenium

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
import time

options=webdriver.FirefoxOptions()
options.preferences["permissions.default.geo"]=1
browser = webdriver.Firefox(options=options)
browser.get('file:///C:/Users/Desktop/test.html')

browser.find_element_by_tag_name("button").click()

input()

You can set other permission by seeing the full list of preferences:

https://support.mozilla.org/en-US/questions/1218174 https://searchfox.org/mozilla-release/source/browser/app/profile/firefox.js

PDHide
  • 18,113
  • 2
  • 31
  • 46