Encapsulation of the automated test framework Selenium API

Source: Internet
Author: User
Tags xpath


Next http://tianxietaotao.blog.51cto.com/12002420/1951701 This article I would like to introduce a brief introduction of this tool

First:

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/9D/42/wKiom1l8o-GDTxnHAADQq-Ebico028.png-wh_500x0-wm_ 3-wmp_4-s_4111642923.png "title=" Tool.png "alt=" Wkiom1l8o-gdtxnhaadqq-ebico028.png-wh_50 "/>

Production background:

Web Automation testing is now becoming more common in the field of testing, but writing code is a weak base for many test ape code, and building a system is cumbersome. So I took my spare time to do this simple tool: Below is a brief introduction to the following functions

Tool Brief Introduction:

1. Toolbar: Resume: Debug Phase execution to next breakpoint Next: Single step debug/run mode switch execution, stop

2, use case tree: Use cases with EXECL or XML maintenance, can be added to the test system

3. Workspace: Easy to execute and debug when single use case is included table viewing use case data, finding a breakpoint when searching for an element to determine if the writing method is correct

4. LOG: Execution log

5. Dispatch Zone: Temporarily support sequential execution, use case adjustment order deletion, etc.



I call this software for personal client version auto, although there are a lot of details need to improve, I still introduce the process I write this software, if there is a reference to the place, welcome to spit Groove.

Good habits first 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0028.gif "alt=" J_0028.gif "/>

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/9D/43/wKioL1l8puuApw97AAIf5-VdpjU901.png-wh_500x0-wm_ 3-wmp_4-s_10519829.png "title=" 950020-20160717202238936-930721942.png "alt=" Wkiol1l8puuapw97aaif5-vdpju901.png-wh_50 "/>


This diagram is the core of the entire software that can be perfected to cover selinum functions. Here everyone Open eyes 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0005.gif "alt=" J_0005.gif "/>

1. Initial idea

Selinum we only focus on two points 1, element 2, action

When I do the software is also divided into two instances 1, find element 2, the implementation of the action with this idea, our first step is to open the Michael

2, the idea refinement

1, model design employing words is that each command of a use case contains content that is abstracted as a Java model

2, use case Source selection execl, XML and other use case source is described here using execl

It's enough for you to implement the first step.

1, used selinum should know selinum each Findelement method return for Webelement Webelement can continue to find elements

We can not cut off this function, chain search is very common. We look at the Webelement Class implementation tree surprise Discovery Webdriver and webelement incredibly realize the same interface. Polymorphic use up 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0058.gif "alt=" J_0058.gif "/>

Find element method design for Portal

1, webelement findelement (Webdriver Dr, Command c) {return findelement (SearchContext, str);} 2, Webelement findelement (SearchContext Dr, string[] str) {while (str.length) {findelement (DR, Str[0])};return Dr;} 3, Webelement findelement (SearchContext dr, String str) {if (Strb.startswith ("XPath:")) {return dr.findelement (By.xpath (Str.substring (6)));} }

So 1 off 2, 2 off 3 3 for the specific model-based reading of the class, so that the problem of element lookup solved


2. Command: The simplest and most foolish way to command is to design the command after the if else if time reason I do the same 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0009.gif "alt= "J_0009.gif"/>


This is the core of the foundation! The packaging of the interface is also very time consuming. The above for everyone to share it!

Encapsulation of the automated test framework Selenium API

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.