WebUI 自动化测试框架 PhoenixAutotest 发布 20170610

栏目: 编程工具 · 发布时间: 7年前

内容简介:WebUI 自动化测试框架 PhoenixAutotest 发布 20170610

介绍

WebUI自动化测试框架phoenix.webui.framework发布20170610版本。

本次发布修正了一些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,请访问“ 素人派 ”。


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Head First JavaScript Programming

Head First JavaScript Programming

Eric T. Freeman、Elisabeth Robson / O'Reilly Media / 2014-4-10 / USD 49.99

This brain-friendly guide teaches you everything from JavaScript language fundamentals to advanced topics, including objects, functions, and the browser’s document object model. You won’t just be read......一起来看看 《Head First JavaScript Programming》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具