Python Test series Tutorials--python+selenium automated test framework __python

Source: Internet
Author: User
Tags generator string format selenium python

Full Stack Engineer Development Manual (author: Shangpeng)

The Python tutorials all solution needs Environment browser (firefox/chrome/ie. Python Selenium Selenium IDE (if using Firefox) FireBug, Firepath (if using Firefox) chromedriver, Iedriverserver, Phantomjs.exe IDE (Pycharm/sublime/eclipse.. )

1, browsers suggest using Firefox or Chrome, do not use the latest version, to use the early two to three versions.
2, Python do not use Python2, and use Python3.
3, Selenium installation use command pip install Selenium
4, Selenium IDE can record playback, can only apply with Firefox browser. exists as a Firefox plug-in plug-in.
5, if you want to use Firefox, the necessary plug-ins are Firebug and Firepath, both can be found in the add-on Component Manager.
6, the fruit needs to use the Chrome browser or IE browser, you need the corresponding driver, download links as follows:
Chromedriver,chromedriver No 64-bit version, 32 can drive:
Http://chromedriver.storage.googleapis.com/index.html

Iedriverserver, the links below can download all versions of the selenium and Iedriverserver,iedriverserver differentiate 32-bit/64-bit:
Http://selenium-release.storage.googleapis.com/index.html

Select the appropriate version and download it.

Find a folder that's easy to find and use when you start the Chrome browser and IE.

Note : Browser test drivers such as Chromedriver and Iedriverserver are both Google browsers and IE browsers that invoke the system, so drivers and browser clients must match each other (and the latest test drivers are often several versions worse than the latest browsers). So download the driver as much as possible to download the latest, in the download browser to try to use the old version. Selenium webdriver Download link

Module Name Module Description Selenium webdriver Download link
Selenium Standalone Server 3.0 This is the latest stable version of Selenium webdriver. You need it when you want to perform a remote Selenium webdriver. Also, note that the RC API is no longer supported by selenium 3.0+. You should use an alternate interface to start the old stuff. Selenium webdriver 3.0 Download (Stable version)
Selenium Java Package (3.0.1), Selenium Python package (3.0.0) These packages include a series of libraries that extend selenium functionality Selenium Java Package 3.0.1 (Stable version), Selenium Python Pack 3.0.0 (Stable version)
IE Server Driver (2.53.1) If you want to start IE to do a Web test, you must have one of these two drivers. Choose according to your system architecture. 32-bit IE server Driver (stable version), 64-bit IE server Driver (stable version)
GECKO Driver (latest edition) This driver is used to support the new version of the Firefox browser, download the latest version from here Mozilla GECKO Driver (Stable version)
Google Chrome Driver (latest edition) Download the latest version of Google Chrome drive from here Google Chrome Driver (Stable version)
yaml file Syntax

YAML is a language dedicated to writing profiles, very concise and powerful, far more convenient than JSON format. Its grammatical rules can refer to: http://blog.csdn.net/luanpeng825485697/article/details/79478338 Giithub Hosting

The architecture code for Automated tests is hosted on GitHub, and readers can download them themselves
Https://github.com/626626cdllp/Test/tree/master/Test_framework Automated Testing Framework

In this automated testing framework.

stored in the Config directory is the test configuration related files, the configuration file can use the INI, XML, yml and other file types. For example, the URL to test, the file name of the debug log, the output format of the log, and so on

The data directory is where you need to test. You can use file types such as XMLS, XML, and so on. For example, test the various content to be submitted in the Web site.

The drivers directory stores the browser drivers that the test needs to use. Mainly for Chromedriver.exe, IEDriverServer.exe, Phantomjs.exe

An output log. log file is stored under the log directory.

A file that stores the HTML class of the test report file in the reporting directory.

Store all test-related files under the testing directory.

– In the Test/case directory, used to store test cases.

– In the Test/common directory, for storing items, page-independent encapsulation.

– In the Test/interface directory, a test case that holds the background interface of the previous role test.

– In the Test/page directory, a repetitive process for storing specific page tests.

– In the Test/suite directory, used to store test suites to organize use cases.

Store public methods under the Utils directory.

The –utils/assertion.py file is used to add various custom assertions (whether the test result and the target result are consistent), and the assertion failure throws the Assertionerror on OK.

The –utils/client.py file is used to test the front-end client of the Web backend interface, to add httpclient to the HTTP interface, and to send an HTTP request. You can also encapsulate TcpClient for TCP links, test socket interfaces, and so on.

The –utils/config.py file is used for the project public content configuration and for reading configuration in the configuration file. Here the configuration file uses the YAML, also may use other like Xml,ini and so on, needs to add the corresponding reader in the File_reader to carry on the processing.

The –utils/extractor.py file is used for the extractor, extracting part of the data from the response result, where the JSON return data is extracted and can be added to its own XML format, normal string format, header's extractor

The –utils/file_reader.py file is used for reading files, including the configuration file and the read function of the data file. Returns what is contained in a file based on the address of the file

The –utils/generator.py file is used for some generator methods, generating random numbers, cell phone numbers, and sequential numbers to test with this data

–utils/htmltestrunner.py is a third-party module that is used to generate test reports for HTML. Readers can not change it.

The –utils/log.py file defines the log level, log file name, log format, and so on, by reading the configuration file.

The –utils/mail.py file is used to send mail to the specified user. Multiple recipients can be specified, with attachments.

–utils/support.py files are used to write support methods, such as signatures, encryption, and other related tips:

If you cannot introduce a custom module in Pycharm, first right-click the project root-> tag directory for resource root in Pycharm, and then right-click the project root directory-> root. This allows you to reference all the custom modules in the project root directory.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.