python脚本运行问题
疑问
同一个脚本,使用sublime text编译报错,使用geany工具又能正常执行,难道是sublime text不能调用selenium么?
代码段如下
# coding=utf-8
from selenium import webdriver
driver = webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(6)
driver.get("https://www.baidu.com")
try:
driver.find_element_by_id("kw")
print ('test pass: ID found')
except Exception as e:
print ("Exception found", format(e))
driver.implicitly_wait(6)
driver.quit()
使用sublime text编译报错如下
Traceback (most recent call last):
File "G:\Users\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "G:\Users\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "G:\Users\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 992, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "FirstScript2.py", line 5, in <module>
driver = webdriver.Chrome()
File "G:\Users\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "G:\Users\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
***Repl Closed***