I haven't programmed in years. I am trying to learn to automate a task for work. I was able to successfully install selenium for Python after having some issues.
This is the simple program I am trying to test to make sure my installation was successful.
Note - I was having issues installing selenium so I had to set the path and some other stuff. So I'm thinking some of those changes might have affected running this Python program.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
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("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
When I run the program on the command prompt this is what I get.
>py main.py
Traceback (most recent call last):
File "C:\Users\jonab\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\jonab\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 947, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\jonab\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1416, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\jonab\Documents\Python Projects\Amazon SC Review Automation\main.py", line 4, in <module>
driver = webdriver.Firefox()
File "C:\Users\jonab\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
self.service.start()
File "C:\Users\jonab\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
I did reference this post and ran their code but got a different error. Python Selenium Traceback (most recent call last):