Issue
I've just installed Spyder IDE (only Spyder, not whole Anaconda) at work and would like to automate my work with FireFox.
My question is, how do I install the Selenium package?
Solution
I figured it out. Here is instruction for Windows:
Install Python:
https://www.python.org/downloads/Install Spyder:
https://www.spyder-ide.org/Run PowerShell or CMD:
Insert following commands:
pip install selenium
pip install webdriver_managerUse command "pip freeze", you should see among others, following libraries installed:
selenium==3.141.0
urllib3==1.26.2
webdriver-manager==3.2.2Open Spyder -> Tools -> PYTHONPATH manager -> Add path
c:\users\Hronic\appdata\local\programs\python\python39\lib\site-packages
Note:
If you don't know the path, in CMD/PowerShell, type "PIP install selenium"
You will get the answer:
"Requirement already satisfied: urllib3 in c:\users\Hronic\appdata\local\programs\python\python39\lib\site-packages (from selenium) (1.26.2)"
Download webdriver - in my case mozilla:
https://github.com/mozilla/geckodriver/releasesIn Spyder, you can type following code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox(executable_path=r'C:\Users\Hronic\Downloads\geckodriver.exe')
driver.get("http://www.python.org")
Note:
- path to just downloaded driver
- this short code should open firefox and webpage "http://www.python.org"
- It should work or rather "works for me" :)
Answered By - Hronic
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.