Preparing selenium automation framework

Automated testing is the process of artificially driving tool to perform tests. The automated testing framework is to make a series of automated testing tools or libraries to achieve a combination package, to help us to automate testing facilities.

The main automated testing framework with a digital drive frame and keyword driven framework two kinds. selenium automated testing framework to belong to data-driven framework. robotframework belong keyword-driven framework.

Preparing selenium automation framework as follows:

1, init configuration file Introduction

sectionTop the ini file section, the key, the value of (name = value) composed, Comment Use semicolon. Ini modifications to meet the different scenes.

语法:[section1] Name1=value   [section2] Name2=value

Case: [port] portname = come4 port = 22

Operation 2, ini configuration file

python is ini file read operation performed by ConfigParser module.

(1) Basic reading operation

①read (filename) reads the contents of the file directly

②sections () to read all the section, and returns a list

③options (section) to get all of the section's option

④items (section) to get all the key-value pairs section

⑤get (section, option) values ​​obtained in the option section, and return a string type

⑥getint (section, option) values ​​obtained in the option section, and return an int

⑦getfloat () and getboolean () function

(2) basic write operation

①write (fp) config object is written to the .ini file format

②add_section (section) to add a new section

③set (section, option, value, on the section of the option is set, you need to call write the contents of the configuration file)

④remove_section (section) to remove a section

⑤remove_option(section,option)

3, Excel operation

selenium is a data-driven framework needs to read the test data from a file, passing through the variable test scripts written in, that is, the separation of data and scripts . Test test scenario often excel data placed on the table, that is, fill in the data to an Excel spreadsheet, the variables are passed through the python test script, so you must install the plug-excel spreadsheet.

pip install xlrd

pip install xlwt

4, the log

Logging python provided by the logging system modules, the system logs into different levels (low, medium, high).

Level priority ordered as follows: NOSET <DEBUG <INFO <WARING <ERROR <CTITICAL

By default, Logging module screen printed on the log, the log level WARINING (i.e., only the logging level) is equal to or higher than WARNING log information will be output to the screen), the log format: warning lever: instace name: wrning message. And logging to a file

Reproduced in: https: //www.jianshu.com/p/3e2c884126ee

Guess you like

Origin blog.csdn.net/weixin_34376562/article/details/91093607