零基础搭建自动化测试框架--001工具选型

       ·           主体框架:Selenium webdriver

       ·           测试执行:Testng

       ·           开发语言:java

       ·           工程类型:maven

       ·           代码仓库:github

       ·           持续集成:Jenkins

 

1、自动化测试框架(Selenium webdriver

目前开源工具使用比较广泛的GUI自动化工具主要包括selenium、sahi、wairt。个人觉得sahi和selenium同样优秀,可能对等待处理等地方更优于selenium。 但是sahi属于半开源软件。社区版本的有很多功能不提供,切目前国内网站能搜到的资料除了官网数据其他资料比较少。

Watir使用方式和selenium类似。但是只支持ruby语言。目前来看ruby的流行程度还不足以支撑一个团队去开发。所以大型团队协作开发还是基于python或者java等语言。

因此selenium是最好的选择。目前支持的社区和可用的资源特别多。同时支持各种语言例如javaC#python等等。且浏览众多招聘网站,对于测试开发岗位或者自动化测试岗位的要求都是必须会selenium appium技能。而且Selenium3已成为W3C标准。因此基于GUI的自动化测试selenium是不二之选

 

以下表格是selenium sahi    seleniumwairt 的比较。

表格来自http://sahipro.com/sahi-vs-selenium/

Recorder

Selenium

Sahi

Works only on Firefox

Works on all browsers (IE, FF, Chrome, Safari, Opera)

Has trouble recording IFrames, Frames and popup windows

Can record on IFrames, Frames and popup windows

For Frames and IFrames, need to explicitly selectFrame

Implicit smart identification of elements even across Frames and IFrames

Uses XPath for identification of elements if id or name not present

Uses various algorithms to uniquely identify elements in a simple human recognizable way

ProgrammingLanguage support

Selenium

Sahi

Java, Ruby, Perl, Python, C# (and may be more).

Sahi Script, Java, Ruby Sahi Script has the syntax of javascript but can interoperate with any Java code directly from script. The Java/Ruby drivers are available since Sahi V3

Needs language bridges for each new feature. For example, needs java bridge to invoke Flash via ExternalAPI.

Sahi Script can directly invoke anything exposed by javascript.

Easeof use

Selenium

Sahi

Easy to start with because of Selenium IDE which is a firefox plugin. Estimated start time less than 5 minutes

More difficult than Selenium to start because it needs installation of Sahi. Estimated start time 10-30 minutes, depending on Java installation etc.

Deep learning curve when the need is felt to move from Selenium IDE to Selenium RC.

There is only one mode of operation for Sahi. Extremely simple to learn and use for testers

Knowledge of programming language required

Can achieve most automation with just functions and variables. Sahi has inbuilt APIs for most other complex tasks like data driven testing

Needs JUnit style of programming

Can choose your own style

Uses XPath based identification for elements in complex html structures or those with dynamic ids. css selectors and javascript may also be used.

Has nearness APIs like _in and _near which can help show nearness of elements. Eg. _image(“delete.gif”, _near(“username 4”))

Needs waits for making AJAX work

No waits needed in 90% cases

Supports parallel execution

Inbuilt parallel execution. Needs only one parameter change





Stability of scripts and easeof maintenance

Selenium

Sahi

Smart DOM Relations resilient to UI changes

No
Dependent on XPath
Difficult for testers to understand and debug

Yes
Does not use XPaths.
Uses _near and _in

Implicit waits for page load and AJAX:
1) Saves time
2) Keeps scripts simple
3) Reduces random failures

No
Explicit waits needed.

Yes

Ease of adoption by a team of testers

Needs testers to know TestNG/Junit, XPaths, HTML structures, Frames IFrame knowledge, Javascript for AJAX conditional waits

Sahi abstracts out all these for the tester.

Dependency on other tools

Selenium – Java (Others need something similar)

Sahi

Needs JUnit (and optionally eclipse) to run tests

No additional tools required. Tests run from the Sahi Controller/command line/ant

Non persistent reporting. Needs TestNG or something similar for that

Persistent HTML reporting which can be shared via URL or file

Stabilityof product and number of releases

Selenium

Sahi

Started 2004(?) in ThoughtWorks

Started 2005 in ThoughtWorks

Version 1 took 5 years, Version 2 planned mid-2010. Moving away from original architecture to WebDriver based architecture

Current release: Version 3 Number of stable releases in 2009: 7

Footprint

Selenium

Sahi

RC: 10.5 MB, Grid 15 MB

less than 2 .5 MB with source

Not sure

Runtime ~ 50MB for 3 parallel threads

Reporting

Selenium

Sahi

Needs external tools to create readable reports

Inbuilt HTML reports with click through to relevant portion of script

Others

Selenium

Sahi

Build tool integration (ant, batch files)

Yes

Yes

Multiple OS support

Yes

Yes

Version Controllable Scripts/Code

Yes

Yes

HTTPS support/redirects

Not sure

Yes

401 Authentication, Windows/NTLM Authentication dialogs

Not sure

Yes

External proxy tunneling

Yes

Yes

In built APIs for data driven testing

No

Yes

Works only with browsers

Yes

Yes

Needs privileged modes on browsers for operation. (Privileged is bad)

Yes

No

Extensible on future browsers

Depends on finding a way to use privileged mode on that browser

Yes. Very little dependency on type of browser.

Editor support

Has good editors in various languages

Editor support for javascript is not as good as for Java.

Supportavailable

Selenium

Sahi

Free support via Forums

Yes

Yes

Paid support available

Yes

Yes

Authoritative training available

?

Yes

 

表格来自:https://dzone.com/articles/selenium-vs-watir

 

Watir

Selenium

Language Approach

ruby

Object oriented

Original release

2008

2004

Popularity today

Worst

Best

Active? Last release

2 weeks ago

2 months ago

Ease of maintaining test cases

1st (uses Selenium under the hood, providing a better API)

2nd, very similar to Watir

Cucumber Integration

Yes

Yes

BrowserStack and SauceLabs integration

Yes

Yes

Page Object pattern

Yes

Yes

Browsers

Chrome

Firefox

Edge

IE

Safari

Firefox latest releases.

IE 7-11

Safari 5.1+

Opera

Chrome

Edge

Headless browsers

Yes

Yes

Locators

Id, Name, CSS selectors, XPath

Id, Name, CSS selectors, XPath

2、测试执行(Testng

 

目前执行自动化脚本,或者单元测试执行框架最好的是testng 和 junit。但是tesng不仅比junit支持更多的注解,比如package、suit、group等等。 而且testng是通过testng.xml文件调用执行。 很方便集成到ant或者maven等配置文件中编译构建中执行。 因此大型的编译构建项目建议使用TestNG编写。

以下图片表格来自:https://www.guru99.com/junit-vs-testng.html>

S.N.

Description

TestNG

JUnit 4

1

Test annotation

@Test

@Test

2

Executes before the first test method is invoked in the current class

@BeforeClass

@BeforeClass

3

Executes after all the test methods in the current class

@AfterClass

@AfterClass

4

Executes before each test method

@BeforeMethod

@Before

5

Executes after each test method

@AfterMethod

@After

6

annotation to ignore a test

@Test(enable=false)

@ignore

7

annotation for exception

@Test(expectedExceptions = ArithmeticException.class)

@Test(expected = ArithmeticException.class)

8

timeout

@Test(timeout = 1000)

@Test(timeout = 1000)

9

Executes before all tests in the suite

@BeforeSuite

n/a

10

Executes after all tests in the suite

@AfterSuite

n/a

11

Executes before a test runs

@BeforeTest

n/a

12

Executes after a test runs

@AfterTest

n/a

13

Executes before the first test method is invoked that belongs to any of these groups is invoked

@BeforeGroups

n/a

14

run after the last test method that belongs to any of the groups here

@AfterGroups

n/a

3、开发语言(java


4、工程类型(maven


5、代码仓库(github


6、持续集成(Jenkins




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值