Im trying to do the obeythetestinggoat tutorial and cant set my geckodriver,
Im working in Win10 64bits
my pip freeze shows:
Django==1.7,selenium==3.141.0,urllib3==1.25.7
i download the geckodriver (geckodriver-v0.26.0-win64) when i try to get the geckodriver version (via $geckodriver --version
) stops and show me a error 'application error'
I think that the error are in the enviroment variables (i was trying to put the file in location where the variables are set (windows/system32 or python/scripts) but nothing works
i also trying this solution (put the file in some file where path are viable) in another computer and works.
I've solve it like this:
pip install webdriver-manager
in Python i wrote following code and run it:
from selenium import webdriver from webdriver_manager.firefox import GeckoDriverManager driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
Now add the path below to your PATH variable (of course replace your_user_name with the one you have there:
c:\users\your_user_name\.wdm\drivers\geckodriver\v0.26.0\win64
At this point geckodriver should be visible be Selenium from Python. Note: geckodriver does not show up when you run pip freeze
STEP 1 > First You Need To Download The v0.26.0 version make sure you download for correct os if you are using window donwload for window and if you are using linux or other download fo them
STEP2 > Put the geckodirver in your python directory
Step3 > write this code
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('your url')
This question have been cropping up pretty often recently. To burst the myth, you don't need to install geckodriver anyway.
To set the geckodriver you need to ensure a couple of things as follows:
Steps:
"C:\Utility\BrowserDrivers"
:
geckodriver-v0.26.0-win64.zip
: The 64-bit Windows OS compatible GeckoDriver geckodriver-v0.26.0-win32.zip
: The 32-bit Windows OS compatible GeckoDriver geckodriver-v0.26.0-winXY.zip
file and extract the geckodriver.exe (eg "C:\Utility\BrowserDrivers\geckodriver.exe"
)Now you can open the command prompt, change the directory and issue the following command:
geckodriver --version
Output:
Now you can use the GeckoDriver to initiate a Firefox Browsing session passing the absolute path of the GeckoDriver as an argument using the following lines of code:
Python:
from selenium import webdriver driver = webdriver.Firefox(executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe', log_path='./Logs/geckodriver.log') driver.get('http://seleniumhq.org/') driver.quit()
Java:
import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class A_Firefox { public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "C:/Utility/BrowserDrivers/geckodriver.exe"); WebDriver driver = new FirefoxDriver(); driver.get("https://stackoverflow.com"); driver.quit(); } }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.