共计 3892 个字符,预计需要花费 10 分钟才能阅读完成。
介绍
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 | |
*/ | |
public class AnnotationPage extends Page | |
{ | |
private Button toLoginBut; | |
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 | |
*/ | |
public class AutoAnnotationTest | |
{ | |
private SettingUtil util; | |
public void setUp() | |
{util = new SettingUtil(); | |
} | |
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(); | |
} | |
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); | |
} | |
public void tearDown() throws IOException | |
{util.close(); | |
} | |
} |
相关链接
PhoenixAutotest 的详细介绍:点击查看
PhoenixAutotest 的下载地址:点击下载
正文完
星哥玩云-微信公众号
