python-- automated testing selenium

1. Install selenium

  Method a (longer): by mounting pip

Network state, enter cmd, in the C: \ Python35 \ Scripts

Enter the command: python -m pip install --upgrade pip press Enter

Input: python -m pip install selenium press Enter

(Or input directly to pip install -U selenium)

 

 

 

  Method two download package is installed, or downloaded directly selenium Package: Source File Type

https://pypi.python.org/pypi/selenium 

 

 

 

After the download, unzip, cmd environment into the directory where the file setup.py

Run the command: python setup.py install command to install

Input: pip list to see if the installation was successful

 

 

 At this time, the package can be incorporated with selenium selenium Import

 

2. Environment Configuration

Chrom browser
to download the Chrome browser, and then download chromedriver, find the corresponding version of Chrome, such as my version is Chrome 78.0.3904.108, on the choice of 78.0.3904.105
Download: http: //chromedriver.storage.googleapis.com/index .html
after the download is complete, extract the files, and then put under chrome installation directory, such as: C: \ Users \ 13945 \ AppData \ Local \ Google \ Chrome \ Application
then add the path environment variable:
find pATH, click edit, add the C: \ Users \ 13945 \ AppData \ Local \ Google \ Chrome \ Application
click OK to add the complete

The best webdriver file after extracting placed under pycharm file path, so to avoid environmental variables mistakes

from selenium import webdriver
import time
t = webdriver.Chrome()
t.get('https://lol.qq.com/main.shtml')
time.sleep(5)
t.close()

运行结果

 

 

 

 运行结果如上图所示就表明成功了

Guess you like

Origin www.cnblogs.com/yezishen/p/12041356.html