Home > OS >  I can't run geckodriver, python selenium ; [WinError 216]
I can't run geckodriver, python selenium ; [WinError 216]

Time:11-16

I've got the win32 drivers from

https://github.com/mozilla/geckodriver/release

and placed the exe under the python38 folder

I'm running windows 11

OSError: [WinError 216] This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher

here you can find the full terminal output

https://pastebin.com/k3Gvm2nU

> `from selenium import webdriver
> from selenium.webdriver.common.keys import Keys
> from selenium.webdriver.common.by import By
> 
> driver = webdriver.Firefox()
> driver.get("http://www.python.org")
> assert "Python" in driver.title
> elem = driver.find_element(By.NAME, "q")
> elem.clear()
> elem.send_keys("l")
> elem.send_keys(Keys.RETURN)
> assert "No results found." not in driver.page_source`

this is the code, I was expecting it to open a firefox page but it doesn't, I think that geckodriver isn't running because its incompatible for some reasons?

CodePudding user response:

You can use webdriver_manager to get rid of driver problems. You can use webdriver_manager for firefox as you can see in the link as follows

for selenium 3

from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())

for selenium 4

from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
from webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))
  • Related