web automated testing ---- test environment to build

1. Instructions for use:

  As used herein, the operating system: win10

  The computer has been installed Python interpreter 3.0 (need can be downloaded from the official web site at: https://www.python.org/ )

2. Environmental installation method (internet connection required oh!):

  1) Check whether the installed python interpreter: win + R -----> Input: cmd Enter ----> Input: python Enter ---> python version information appears, showing the python interpreter is installed normally -----> input exit () to exit the interpreter environment python

  2) win + R ----> Input: cmd Enter ----> Input: pip Enter ------> the following text

              Usage:

              pip <command> [options]

              Commands:
              install .................. ----> represents pip command can be used

  3) win + R ---> Input: cmd Enter the following:

    View installed packages: pip show package name (here is Selenuim package)

    Installation package: pip install the package name (pip install selenium)

    Uninstall package: pip uninstall package name (pip uninstall selenium)

    Lists the package name: pip list

  4) browser and the corresponding driver (version agreed to)

     The browser driven into the PATH (this embodiment is placed in the home directory of python)

3. Detection installation environment

  In order to facilitate efficient to write code using the IDE tools pycharm (need to download the official website, URL: https://www.jetbrains.com/ )

  New items are omitted here and other operations

  Write test scripts, reads as follows:

# 0.导入webdriver
from selenium import webdriver
import time

# 1. Create Object Browser drive - class instantiate the class name () 
Driver = webdriver.Chrome ()

# 2. Object Browser drive .get ( "full URL") 
driver.get ( " http://baidu.com/ " )

# 3. Business Operation - operating elements and the positioning elements 
the time.sleep (. 3 )

# 4. Exit browser drive object .quit () 
driver.quit ()

  Baidu successfully opened a page in a browser, and automatically turn off after three seconds to indicate the environment has been installed over the

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/lemonBaby/p/11924137.html
Recommended