Python geckodriver set up is unsuccesful

23 views Asked by At

I have a problem with geckodriver.exe.

I am going to create a bot but I dont know how to set up mozilla driver.

from selenium import webdriver 

geckodriver_yolu = "./geckodriver.exe" 

tarayici = webdriver.Firefox(executable_path=geckodriver_yolu)

tarayici.get("https://www.youtube.com")

enter image description here

1

There are 1 answers

0
Shawn On

If you are using latest selenium version(v4.6.0 or above), then code can be as simple as:

from selenium import webdriver

tarayici = webdriver.Firefox()
tarayici.get("https://www.youtube.com")

Selenium Manager will take care of driver management, no need to worry about setting geckodriver.exe path manually.

Refer this answer - https://stackoverflow.com/a/76463081/7598774

And for any reason, if you wish to set the driver path manually, then below the code:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

service = Service(executable_path="C:/<fullpath>/geckodriver.exe")

tarayici = webdriver.Firefox(service=service)
tarayici.get("https://www.youtube.com")