我已经好几年没编程了。我正在努力学习将工作任务自动化。在遇到一些问题后,我成功地安装了selenium for Python
这是一个简单的程序,我正试图测试,以确保我的安装是成功的
注意-我在安装selenium时遇到问题,所以我必须设置路径和其他一些东西。因此,我认为其中的一些更改可能会影响Python程序的运行
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()
当我在命令提示符下运行程序时,我得到的就是这个
>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.
我确实引用了这篇文章并运行了他们的代码,但得到了一个不同的错误。 Python Selenium Traceback (most recent call last):
目前没有回答
相关问题 更多 >
编程相关推荐