这篇文章主要介绍了PhoenixAutotest怎么使用的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇PhoenixAutotest怎么使用文章都会有所收获,下面我们一起来看看吧。

PhoenixAutoTest是一个基于 Selenium 的Web自动测试框架,通过该框架可以简化测试人员的学习难度,只要 编写少量的Java代码即可,大多数的工作都是编写页面元素的描述文件以及对应的数据源。

介绍

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

增加了通过注解的方式来配置PageObject(页面对象),单元测试代码如下:

/****Copyright2002-2007theoriginalauthororauthors.****LicensedundertheApacheLicense,Version2.0(the"License");**youmaynotusethisfileexceptincompliancewiththeLicense.**YoumayobtainacopyoftheLicenseat****http://www.apache.org/licenses/LICENSE-2.0****Unlessrequiredbyapplicablelaworagreedtoinwriting,software**distributedundertheLicenseisdistributedonan"ASIS"BASIS,**WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.**SeetheLicenseforthespecificlanguagegoverningpermissionsand**limitationsundertheLicense.**/packageorg.suren.autotest.web.framework.page;importorg.suren.autotest.web.framework.annotation.AutoDataSource;importorg.suren.autotest.web.framework.annotation.AutoLocator;importorg.suren.autotest.web.framework.annotation.AutoPage;importorg.suren.autotest.web.framework.annotation.AutoStrategy;importorg.suren.autotest.web.framework.core.LocatorType;importorg.suren.autotest.web.framework.core.StrategyType;importorg.suren.autotest.web.framework.core.ui.Button;importorg.suren.autotest.web.framework.core.ui.Text;/***使用注解的示例Page类*@authorsuren*@date2017年6月7日下午7:10:40*/@AutoPage(url="http://maimai.cn/")@AutoDataSource(name="data",resource="dataSource/xml/user_data_anno.xml")publicclassAnnotationPageextendsPage{@AutoStrategy(type=StrategyType.PRIORITY)@AutoLocator(locator=LocatorType.BY_PARTIAL_LINK_TEXT,value="实名动态")privateButtontoLoginBut;@AutoLocator(locator=LocatorType.BY_XPATH,value="//input[@placeholder='请输入手机号码/脉脉号']")privateTextphoneText;publicButtongetToLoginBut(){returntoLoginBut;}publicvoidsetToLoginBut(ButtontoLoginBut){this.toLoginBut=toLoginBut;}publicTextgetPhoneText(){returnphoneText;}publicvoidsetPhoneText(TextphoneText){this.phoneText=phoneText;}}

测试代码如下:

/****Copyright2002-2007theoriginalauthororauthors.****LicensedundertheApacheLicense,Version2.0(the"License");**youmaynotusethisfileexceptincompliancewiththeLicense.**YoumayobtainacopyoftheLicenseat****http://www.apache.org/licenses/LICENSE-2.0****Unlessrequiredbyapplicablelaworagreedtoinwriting,software**distributedundertheLicenseisdistributedonan"ASIS"BASIS,**WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.**SeetheLicenseforthespecificlanguagegoverningpermissionsand**limitationsundertheLicense.**/packageorg.suren.autotest.web.framework.util;importorg.junit.*;importorg.springframework.context.annotation.ComponentScan;importorg.springframework.context.annotation.Configuration;importorg.suren.autotest.web.framework.IgnoreReasonConstants;importorg.suren.autotest.web.framework.page.AnnotationPage;importorg.suren.autotest.web.framework.settings.DriverConstants;importorg.suren.autotest.web.framework.settings.SettingUtil;importjava.io.IOException;/***测试使用注解配置的方式*@authorsuren*@date2017年6月7日下午7:10:12*/@Configuration@ComponentScan(basePackages="org.suren.autotest.web.webframework.page")publicclassAutoAnnotationTest{privateSettingUtilutil;@BeforepublicvoidsetUp(){util=newSettingUtil();}@TestpublicvoidbasicTest(){util.getEngine().setDriverStr(DriverConstants.DRIVER_HTML_UNIT);util.getEngine().init();AnnotationPagepage=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)publicvoidrealTest(){util.getEngine().setDriverStr(DriverConstants.DRIVER_CHROME);util.getEngine().init();util.initData();AnnotationPagepage=util.getPage(AnnotationPage.class);page.open();page.getToLoginBut().click();page.getPhoneText().fillNotBlankValue();ThreadUtil.silentSleep(3000);}@AfterpublicvoidtearDown()throwsIOException{util.close();}}

关于“PhoenixAutotest怎么使用”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“PhoenixAutotest怎么使用”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注亿速云行业资讯频道。