系统环境 mac python3.6 pip instal selenium #安装selenium模块,默认是最新的ye可以pip instal selenium==版本号 brew install geckodriver #下载安装geckodriver 或者直接去selenium官网下载https://github.com/mozilla/geckodriver/releases geckodriver-v0.20.0-macos.tar.gz解压到指定目录,或者配置到python环境中/usr/local/bin。 Firefox浏览器版本59.0.2 报错 elenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH,是因为geckodriver的没有在环境变量中识别到
报错 selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities,是因为浏览器的版本和驱动的版本不一致 测试一下 - #!/usr/bin/env python
- # -*- coding: UTF-8 -*-
- from selenium import webdriver
- import time
- #driver = webdriver.Firefox(executable_path="/usr/local/bin/geckodriver")
- driver = webdriver.Firefox(executable_path="/Users/wang/Downloads/geckodriver")
- driver.get("http://www.baidu.com")
- driver.find_element_by_id("kw").send_keys("测试")
- driver.find_element_by_id("su").click()
- time.sleep(30)
- driver.quit()
复制代码
|