欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

记录: python-splinter 的使用过程

程序员文章站 2024-02-10 13:35:10
...
from splinter.browser import Browser

with Browser(driver_name="chrome") as browser:
    # Visit URL
    url = 'http://baidu.com'
    browser.visit(url)
    browser.fill('q', 'splinter - python acceptance testing for web applications')
    button = browser.find_by_name('btnG')

    button.click()

    if browser.is_text_present('splinter.readhedocs.io'):
        print('Yes, the official website was found!')
    else:
        print('No, it wasn\'t found... We need to improve our SEO techniques..')


C:\Users\jame\PycharmProjects\untitled>python spl.py

Traceback (most recent call last):
  File "C:\Users\jame\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
    stdin=PIPE)
  File "C:\Users\jame\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Users\jame\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
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 "spl.py", line 3, in <module>
    with Browser(driver_name="chrome") as browser:
  File "C:\Users\jame\AppData\Local\Programs\Python\Python36-32\lib\site-packages\splinter\browser.py", line 63, in Browser
    return driver(*args, **kwargs)
  File "C:\Users\jame\AppData\Local\Programs\Python\Python36-32\lib\site-packages\splinter\driver\webdriver\chrome.py", line 35, in __init__
    self.driver = Chrome(chrome_options=options, **kwargs)
  File "C:\Users\jame\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 68, in __init__
    self.service.start()
  File "C:\Users\jame\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