Python-selenium Multi-browser support test framework

Source: Internet
Author: User

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

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.