輸入代碼如下:
from selenium import webdriver
import time
brower = webdriver.Chrome()
brower.get('http://www.taobao.com/')
input = brower.find_element_by_id('q')
input.send_keys('iphone')
time.sleep(1)
input.clear()
input.send_keys('ipad')
button = brower.find_element_by_class_name('btn-search')
button.click()
運行結果:r/bin/python3.5 /home/eric/PycharmProjects/untitled12/stt.py
Traceback (most recent call last):
File "/home/eric/.local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib/python3.5/subprocess.py", line 947, in init
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/eric/PycharmProjects/untitled12/stt.py", line 3, in
brower = webdriver.Chrome()
File "/home/eric/.local/lib/python3.5/site-packages/selenium/webdriver/chrome/webdriver.py", line 62, in init
self.service.start()
File "/home/eric/.local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 81, 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/h