MacOS:
1. Install Pycharm and create a new project. Project interpreter selected the path of my locally installed python2.7:/usr/bin/python
2. Open the Selenium Python language download page: https://pypi.org/project/selenium/, view the installation process above:
- Open Terminal, RUN:PIP, if prompted not to know the PIP command, you need to install PIP first:
- Open https://pip.pypa.io/en/stable/installing/
- Run: Curl HTTPS://bootstrap. Pypa. Io/get-pip. Py -o get-pip. PY
- Run: python get-pip. PY--user
- Run:pip should know the PIP order this time.
- In terminal, Run:pip install-u Selenium
- Open Pycharm, open the project's Preferences page, click on Project Interpreter, click on the lower left corner of +--select Selenium, click Install Package, Selelium Import Successful .
- Download Browser driver: https://www.seleniumhq.org/download/
- Write a test code inside Pycharm to see if selenium works:
# !/usr/bin/python # -*-coding:utf-8-*- from Import Webdriver from Import = Webdriver. Chrome ("/users/xx/pycharmprojects/pythonexercise/chromedriver")// Notice that this changes to the address of your downloaded browser driver driver.get ("http://www.baidu.com") sleep ( driver.quit ()
Python+pycharm+selenium (MacOS)