I. Directory structure
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/DD/wKioL1XvCgWBGaF2AAExq5BnqZI578.jpg "title=" Mulu.png "alt=" Wkiol1xvcgwbgaf2aaexq5bnqzi578.jpg "/>
Two. Design mode
Based on the Page-object design pattern
1.lib-base
util--implementing a Read configuration file
driver_manager--start a different browser with the type parameter driver
test_manager--creating different classes with the type parameter for multi-browser support
2.lib-page
Abstract_page implementation
Read configuration: URL, user information
Login function
*: Note When debugging alone need to add Sys.path.append (R ' D:\test_browser ') at the beginning, otherwise from lib.base.util import util will error
Xxxpage implements each page page feature, such as creating bugs, creating document features
3.case
Test_abstract implementation
Member Variable Type,driver,config_file
Driver start and stop in Setup and teardown
Function
Testxxxpage implementing each page page test case
Write a page and write the corresponding case
Three. Configuration Management
Using the Configparser module
[INFO]
url=http://127.0.0.1:8888/xxx/
Admin_user=admin
admin_pswd=123456
Admin_name= Administrator
qa_user=test01
qa_pswd=123456
Qa_name= Test 1
rd_user=test02
rd_pswd=123456
Rd_name= Test 2
[Test]
Dir_screenshot=d:/test_browser/data/screenshot
Import Configparserconfig=configparser.configparser () config.read (' base.conf ') print config.get (' info ', ' qa_user ')
Four. Multi-browser
Use class inheritance to generate classes for different browsers for multi-browser support
From new import Classobjclass Testmanager: @staticmethoddef gettest (Clz,type): New_classname=str (clz.__name__) + '-' + STR (type). Capitalize () #驼峰式写法, first uppercase New_clz=classobj (New_classname, (CLZ,), {' Type ': type}) return Unittest.makesuite (NEW_CLZ)
This article from "Today's efforts, tomorrow's success!" "Blog, be sure to keep this provenance http://zhzhgo.blog.51cto.com/10497096/1692951
Python-selenium multi-browser support test framework