mac system installation selenium

1. premise

(1) mac system comes python2.7, if you want the python3 version, so you need to download and install.

(2) installed IDE: pycharm

(3) installed chrome browser

(4) Download chromedriver: http://npm.taobao.org/mirrors/chromedriver/2.36/ (into the User / local /
bin) ----------------

Installation selenium Operation:

Open a terminal, enter: sudo pip3 install selenium (python2 version of the input sudo pip install selenium) 

After the installation is complete

webdriver the Selenium Import from 
Import Time 

WD = webdriver.Chrome () # open Chrome 
## open Baidu browser 
wd.get ( 'https://www.baidu.com') 
# position the input box and enter the keyword 
wd. find_element_by_id ( 'kw'). send_keys ( 'the Selenium') 
# click [Baidu,] search 
wd.find_element_by_id ( 'su'). the click () 
the time.sleep (5) 
wd.quit () # close the browser

 

If you prompted sudo: pip: command not found, explain the lack of pip, pip need to install their own.

Installation pip: Open the terminal input sudo pip3 install numpy (python2 version of the input sudo pip install numpy)

Uninstall pip: Open a terminal, enter sudo pip3 uninstall numpy

Guess you like

Origin www.cnblogs.com/suancaipaofan/p/11748227.html