本次发布修正了一些bug,更多Isseus信息请访问Github。添加的主要功能如下:
增加了通过注解的方式来配置PageObject(页面对象),单元测试代码如下(本文所有的代码都可以在Github项目中获取):
/*
*
* * Copyright 2002-2007 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.suren.autotest.web.framework.page;
import org.suren.autotest.web.framework.annotation.AutoDataSource;
import org.suren.autotest.web.framework.annotation.AutoLocator;
import org.suren.autotest.web.framework.annotation.AutoPage;
import org.suren.autotest.web.framework.annotation.AutoStrategy;
import org.suren.autotest.web.framework.core.LocatorType;
import org.suren.autotest.web.framework.core.StrategyType;
import org.suren.autotest.web.framework.core.ui.Button;
import org.suren.autotest.web.framework.core.ui.Text;
/**
* 使用注解的示例Page类
* @author suren
* @date 2017年6月7日 下午7:10:40
*/
@AutoPage(url = "http://maimai.cn/")
@AutoDataSource(name = "data", resource = "dataSource/xml/user_data_anno.xml")
public class AnnotationPage extends Page
{
@AutoStrategy(type = StrategyType.PRIORITY)
@AutoLocator(locator = LocatorType.BY_PARTIAL_LINK_TEXT, value = "实名动态")
private Button toLoginBut;
@AutoLocator(locator = LocatorType.BY_XPATH, value = "//input[@placeholder='请输入手机号码/脉脉号']")
private Text phoneText;
public Button getToLoginBut() {
return toLoginBut;
}
public void setToLoginBut(Button toLoginBut) {
this.toLoginBut = toLoginBut;
}
public Text getPhoneText() {
return phoneText;
}
public void setPhoneText(Text phoneText) {
this.phoneText = phoneText;
}
}
测试代码如下:
/*
*
* * Copyright 2002-2007 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.suren.autotest.web.framework.util;
import org.junit.*;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.suren.autotest.web.framework.IgnoreReasonConstants;
import org.suren.autotest.web.framework.page.AnnotationPage;
import org.suren.autotest.web.framework.settings.DriverConstants;
import org.suren.autotest.web.framework.settings.SettingUtil;
import java.io.IOException;
/**
* 测试使用注解配置的方式
* @author suren
* @date 2017年6月7日 下午7:10:12
*/
@Configuration
@ComponentScan(basePackages = "org.suren.autotest.web.webframework.page")
public class AutoAnnotationTest
{
private SettingUtil util;
@Before
public void setUp()
{
util = new SettingUtil();
}
@Test
public void basicTest()
{
util.getEngine().setDriverStr(DriverConstants.DRIVER_HTML_UNIT);
util.getEngine().init();
AnnotationPage page = util.getPage(AnnotationPage.class);
Assert.assertNotNull(page);
Assert.assertNotNull(page.getUrl());
Assert.assertNotNull(page.getToLoginBut());
page.open();
page.getToLoginBut().click();
}
@Test
@Ignore(value = IgnoreReasonConstants.REAL_BROWSER)
public void realTest()
{
util.getEngine().setDriverStr(DriverConstants.DRIVER_CHROME);
util.getEngine().init();
util.initData();
AnnotationPage page = util.getPage(AnnotationPage.class);
page.open();
page.getToLoginBut().click();
page.getPhoneText().fillNotBlankValue();
ThreadUtil.silentSleep(3000);
}
@After
public void tearDown() throws IOException
{
util.close();
}
}
期待更多更好用的功能请您持续关注本项目。支持开源,支持中国开源项目!!!
•参考
本文为原创,如果您当前访问的域名不是surenpi.com,请访问“
素人派”。
分享到:
相关推荐
github地址: https://github.com/wuranxu/webTest 基于Python的webUI自动化测试框架,支持多平台~带有自动下载chrome驱动功能
本项目是一个基于Selenium的Web自动测试框架,通过该框架可以简化测试人员的学习难度,只要编写少量的Java代码即可,大多数的工作都是编写页面元素的描述文件以及对应的数据源。
使用Java+Maven+Selenium+TestNG+Jedis+Jenkins搭建的WebUI自动化测试框架,资源的大体介绍如下链接http://note.youdao.com/noteshare?id=dc564343fd126f497074f6d7560c9f5e&sub=387EB3B1BAC945CEA71A5BDBC6484473
这是一款无需编码即可实现WebUI自动化测试的平台。为了方便新手尽快熟悉平台,每一页都有帮助向导!
Dagger是网易杭州研究院QA团队开发的一个轻量级、运行稳定的WebUI自动化测试框架,主要基于Selenium及TestNg可以认为是对Selenium进行二次封装的一个框架(俗称 造轮子 )。之所以把这个轮子开源出来,主要在于...
基于Python的webUI自动化测试框架,支持多平台~ 支持xmind文件转为测试用例,目前存在部分问题 支持chrome驱动自动下载 支持用例重跑及自动错误截图 使用antd美化html报告 采用po模式,定位元素与实际操作分离,同...
写过UI自动化测试脚本的朋友,相信都会遇到过,比如前端页面元素改了,又需要去改自己写的脚本,而且只能针对某个web页面的定制化设计,换个web项目就不灵了。 我就在考虑,为什么UI自动化框架就不能通用在不同的...
Web UI自动化测试总结以及unittest框架初识.zip
phoenix.webui.framework, 基于WebDriver的WebUI自动化测试框架.zip
WEB自动化测试框架文档.docWEB自动化测试框架文档.docWEB自动化测试框架文档.docWEB自动化测试框架文档.docWEB自动化测试框架文档.docWEB自动化测试框架文档.doc
自动化测试框架,支持接口自动化、WEB UI自动化、APP UI自动化、性能测试;支持多系统相互调用;支持接口与UI相互调用;支持dubbo接口调用.zip 适合学习/练手、毕业设计、课程设计、期末/期中/大作业、工程实训、...
Web UI自动化测试框架(基于Selenium) 框架简介 基于python语言对selnium做的二次封装,主要有以下特点: 1.采用了主流的po模式2.实现了日志的记录与输出3.美观的测试报告输出4.灵活的测试用例获取5.数据库连接6....
WebUI自动化测试项目,支持截图和录屏,一个元素多种定位方式
写过UI自动化测试脚本的朋友,相信都会遇到过,比如前端页面元素改了,又需要去改自己写的脚本,而且只能针对某个web页面的定制化设计,换个web项目就不灵了。 我就在考虑,为什么UI自动化框架就不能通用在不同的...
web自动化测试框架及实践,应用python+selenium+pytest集成了web页面的功能巡检、写测试报告以及邮件发送测试结果等功能。
自己动手写Web自动化测试框架,很不错的书籍
springboot、Dubbo、MySQL,源码web系统,框架,代码均经过严格测试,可直接运行,有需要可自取
本框架只是对 selenium( webdriver ) 原生方法进行了简单的封装,精简为大约 30 个方法,这些方法基本能够胜任于我们的web自动化测试。基于 unittest 单元测试框架,所以测试文件与测试方法遵循unittest开发。自动...
Web自动化测试框架搭建:内含自动化测试理念介绍及分层的自动化测试框架搭建,整个自动化测试采用CI管理