python + selenium environment to build step

I. Introduction Automation

1. The concept of automated testing:

      Is a process that the human-driven test machine to perform the conversion of which test procedure is a process procedure in

2. Automated Test Category:

Automation of said general functional testing is automated testing, using a program to test the functionality of the software by a coding method, so that the program may be repeated for the purpose of the test is repeated. If a small portion of the software function changes, as long as the modified part of an automated test code, you can repeat the software testing to improve test efficiency.

3. What kind of projects suitable for automated testing:

      Under normal circumstances, as long as the following three cases it can be done automated testing

      Software requirements change frequently, long project cycle, automated test scripts can be reused

Two, python + selenium automated test environment to build step

For many white want to learn in terms of automation, build environment, has always been a very troublesome thing, let's automation environment based on the Python language to the building, python + selenium automated test environment consists of four parts: python , selenium, chrome Google browser, chrome Google browser driven. Wherein the browser may be Firefox, IE and the like. Currently automation mainstream browser or Google chrome browser

(1) python installation

Currently testing industry, the most widely used programming language Python undoubtedly headed. python version 3.7 is now mainstream. Installation is simple, the official website (official website address: https://www.python.org ) to select the corresponding system version downloaded directly, and then double-click to install, customize the installation path may not necessarily need to be installed in the C drive, but avoid Chinese path as possible.

After the python installation package, you need to configure the environment variables, in fact, during the installation of 3.7, the first interface has a "add python to path" option can be checked (presumably the name). Will automatically add the python after checking in to the system environment variable Path. Of course, you can also choose to manually add, add the following method:

My Computer and select properties -> Advanced System Settings -> Environment Variables -> Environment Variables -> System Variables: path to find and modify variables, the path is added in front Path: C: \ Python37; C: \ Python37 \ Scripts; (if your python installed in other path, please make the appropriate changes, the author here is the default path)

Particular attention: Many novice Path in original content will be deleted, I remind you this is absolutely unable to do so, be careful! careful! careful!

After the installation, operation CMD window, type python instruction, for checking whether the installation is successful python. The following figure represents a success!

Attached on the official Download python development tools PyCharm of: http: //www.jetbrains.com/pycharm/download/

(2) selenium mounting

pip selenium can be installed by the command, installation is as follows:

1. Open a cmd window

2. Enter: pip install selenium

3. Wait cmd window prompts successful, the selenium successful installation, such as interrupted halfway continue to enter pip install selenium re-install, does not affect!

(3) chrome browser

Too much current Internet browser to download Google pit, many sites do with too much like official website. Accidentally into the pit, where I download Chrome official website address:

Chrome official website: https://www.google.cn/chrome/

Double-click automatically installed after the download is complete. Wait for the installation to complete.

(4) install chrome browser driver

Why do you need to drive it? This has to start from the principle of selenium to speak of:

       When Selenium proposed the concept WebDriver, which provides an interface using a browser native, packaged in a more object-oriented Selenium WebDriver the API, directly operating the browser page in the elements, and even operating the browser itself (screen, window size, startup, shutdown, installed plug-ins).

       The use of the native browser interface, greatly increased the speed and stability of the calls to the browser vendors themselves, apparently more scientific. But bring some side effects is that different browser vendors, operating elements on the Web and how many there will be some differences in presentation, which directly led to points Selenium WebDriver different browser vendors, and provides different implementations. Such as Firefox have special geckoDriver drive, Chrome will have a special Chrome drives.

Here particular attention: chrome browser and browser version of the drive must be installed chrome correspondence. So how do you ensure that correspond to it?

1. check chrome version of the browser: Click on the upper right corner of three chrome browser -> Help -> About Google Chrome, as shown below:

2.chrome browser Driver Download:

Chromedriver driver download address: http: //npm.taobao.org/mirrors/chromedriver/

On the map and find the closest version of the chrome version: Pictured: 78.0.3904.108, so drive options here:

After the download is complete: the chrome package into the drive: C: \ directory under python37 (this is a must)

Third, you can then open the selenium automation tour

If you think this article helpful to you, if you software testing, interface testing, automated testing, interviewing experience exchange
of interest can be added to software testing exchange group: 695 458 161, the group from time to time distribution of free information, as well as a peer
from exchange of technology. These data are the essence of the author of more than a decade to test career.

Go and try Pycharm enter the following code in, see if you can automatically open the chrome browser, if you can open then the python + selenium automated test environment has become a great service by!

from selenium import webdriver

driver = webdriver.Chrome()



Super comprehensive testing of IT technology courses to learn 0 yuan to join immediately! A friend in need stamp:
Tencent classroom testing technology learning address

 

Guess you like

Origin www.cnblogs.com/csmashang/p/12630264.html