[python3] selenium3+chrome driver+python3 under Mac

Environment: python3.6.4 seleinum3.11

Prepare the python3 environment and install Google Chrome in advance

 

1 Install seleinum

pip3 install selenium

2 Install the chrome driver

Download the latest version of mac chrome driver (requires FQ), 

Link address: https://sites.google.com/a/chromium.org/chromedriver/downloads , follow the arrow and click it

 

3 Configuration: 

 Unzip the downloaded archive and move chromedriver to the /usr/local/bin directory via the command line

mv chromedriver  /usr/local/bin

 

4 Test scripts:

# coding=utf-8
from selenium import webdriver

driver = webdriver.Chrome()
driver.get("http://www.baidu.com")
driver.find_element_by_id('kw').send_keys('selenium')
driver.find_element_by_id('su').click()

 At this time, it will automatically open Google and search

 

 

Extras:

Errors encountered during operation:

1 chromedriver executable needs to be in PATH

   The reason for the error, the chromedriver was not moved to the /usr/local/bin directory

2 unknown error: call function result missing 'value'

   Error reason: chromedriver is not the latest, go to the official website to download the latest

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324498603&siteId=291194637