The construction of selenium+python on the mac environment

foreword

The mac comes with a python2.7 environment, so it is very simple to install the selenium environment on the mac, just enter 2 instructions to install it

Software to be installed:

1.pip

2.selenium2.53.6

3.Firefox44.dmg

4.Pycharm

(The environment is compatible with selenium2+Firefox46 and below, selenium3+Firefox47+geckodriver)

First, selenium installation

1.Mac comes with python2.7, and python comes with the easy_install tool, so install pip with easy_install.

pip is a tool for installing python packages. After this is installed, it is very convenient to install other packages later.

$ sudo easy_install pip

2. The latest version of selenium is 3.0. I won't say much about the difference between selenium2 and selenium3. Here, the editor recommends installing selenium 2.53.6 version. Continue to enter the following instructions to install it.

$ sudo pip install selenium==2.53.6

 

2. Check the version number with pip

1. If you have installed selenium before and want to check the version number, you can use pip show selenium to check.

$ pip show selenium

2. If you want to view all third-party packages currently installed by python, you can use pip show list to view

$ pip show list

 

3. Uninstall selenium

1. If you have installed selenium3 before and want to downgrade to selenium2, you can uninstall selenium first

$ sudo pip uninstall selenium

2. Proceed(y/n)? is prompted, just enter y

3. After the uninstallation is successful, follow the first step to install selenium with pip

$ sudo pip install selenium==2.53.6

 

Fourth, check the selenium environment

1. After installation, you must first check whether your environment is installed properly. First download and install the Firefox44 version of the browser (QQ group files have dmg download package: 232607095) 2. Enter the python environment

$ python

3. Then pour the selenium package, start the browser, and open the Baidu page, which can successfully indicate that the environment is OK

>>>from selenium import webdriver

>>>driver=webdriver.Firefox()

>>>driver.get("https://www.baidu.com")

 

Five, pycharm installation

1. First go to the pycharm official website to download a dmg package, address: https://www.jetbrains.com/pycharm/download/

2. Just select the Professional version of the mac version, and install it foolishly after downloading

 

3. Open the software, fill in http://xidea.online in the License server address, and then click Activate to successfully crack it!

Start your hello world! journey next

Guess you like

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