0

I am trying to build a TinderBot.

Both Chrome and FireFox ask for geo permission outside of code (the pop-up drops from the browser's address bar, so it's not inside the html and I cannot access it with .find_element)

I found some prompts on Chrome here: https://testingbot.com/support/selenium/permission-popups (didn't try it though, so not sure if they are up to date)

But I cannot find anything for FireFox.

I found this piece of code that disables javascipt https://www.selenium.dev/documentation/webdriver/capabilities/firefox/ And I believe that I could build on it, but I cannot find how to set it so that it gives permission for geolocation.

Recently I though I found here a piece that at least might show me how to correctly pass '-hedless' argument but it won't open browser now.

from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from webdriver_manager.firefox import GeckoDriverManager
from selenium.webdriver.firefox.options import Options

opts = Options()
opts.add_argument('-headless')
srvc = Service(GeckoDriverManager().install())
driver = webdriver.Firefox(options=opts, service=srvc)

So generally I have 2 problems here:

  1. How do I make add_argument work? (I mean other cases turned out deprecated)
  2. What arguments do I need to target to allow geolocation on launching browser with the bot?

Am I even on the right path? I cannot ask questions in relevant threads because of insufficient rating, so here I am.

1 Answers1

0

To initiate Firefox browser in headless mode instead of using add_argument() you need to set the headless property to true as follows:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

opts = Options()
opts.headless = True
srvc = Service(GeckoDriverManager().install())
driver = webdriver.Firefox(options=opts, service=srvc)

You can find a relevant discussion in How to make Firefox headless programmatically in Selenium with Python?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352