phoenixframework自动化测试平台webUI代码示例
2016-01-22 00:00
344 查看
摘要: 示例演示了如何在做到定位信息和代码分离,以及不需分离时的规则
package org.phoenix.cases; import java.util.HashMap; import java.util.LinkedList; import java.util.Map.Entry; import org.phoenix.enums.LocatorType; import org.phoenix.model.CaseLogBean; import org.phoenix.model.InterfaceBatchDataBean; import org.phoenix.model.LocatorBean; import org.phoenix.model.UnitLogBean; import org.phoenix.proxy.ActionProxy; /** * 浏览器驱动测试类: * 通用方法API:phoenix.commonAPI().... * webUI/mobileUI用例API:phoenix.webAPI().... * 接口测试用例API:phoenix.interfaceAPI().... * androidappAPI:phoenix.androidAPI().... * IOSappAPI:phoenix.iosAPI().... * svnClientAPI:phoenix.svnClient().... * ftpClientAPI:phoenix.ftpClient().... * socketClientAPI:phoenix.telnetClient().... * ... * @author mengfeiyang */ public class TestBrowserDriver extends ActionProxy{ private static String caseName = "浏览器驱动测试用例"; public TestBrowserDriver() {} @Override public LinkedList<UnitLogBean> run(CaseLogBean caseLogBean) { init(caseLogBean);//必须有这一步 //phoenix.webAPI().setFirefoxExePath("D:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");//使用Firefox浏览器时,必须添加 //phoenix.webAPI().setChromeDriverExePath("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver64.exe");//使用chrome浏览器时,必须添加,且chromedriver64.exe必须和chrome.exe在同一目录下 HashMap<InterfaceBatchDataBean, HashMap<String, String>> datas = phoenix.commonAPI().loadWebCaseDatas(caseName);//加载数据库测试数据方法 HashMap<String,LocatorBean> locators = phoenix.commonAPI().addLocator(caseName);//加载定位信息的方法 for(Entry<InterfaceBatchDataBean, HashMap<String, String>> es : datas.entrySet()){ InterfaceBatchDataBean batchData = es.getKey(); batchData.getExpectData();//这批数据的执行结果期望值 HashMap<String, String> dataBlocks = es.getValue(); String phoenixframe = dataBlocks.get("输入数据1");//在数据库中此数据的key phoenix.webAPI().openNewWindowByFirefox("http://www.baidu.com"); //phoenix.webAPI().openNewWindowByChrome("http://www.baidu.com"); //phoenix.webAPI().openNewWindowByIE("http://www.baidu.com"); //phoenix.webAPI().openNewWindowByHtmlUnit("http://www.baidu.com", true, BrowserVersion.INTERNET_EXPLORER); //phoenix.webAPI().openNewWindowByPhantomJs("http://www.baidu.com"); phoenix.webAPI().webElement("//*[@id=\"kw\"]",LocatorType.XPATH).setText(phoenixframe);//引用数据 phoenix.webAPI().webElement(locators.get("btnLocator").getLocatorData()).click();//使用数据中的定位信息,等同于phoenix.webAPI().webElement("btnLocator").click(); String r = phoenix.webAPI().webElement("//*[@id=\"su\"]", LocatorType.XPATH).getAttribute("value");//数据库中的数据可以与页面不变的数据混合使用 phoenix.checkPoint().checkIsEqual(r, "百度一下");//调用检查点,检查结果会在日志中统计 phoenix.commonAPI().addLog("我是自定义的");//可以手动插入一句日志,该日志会在最后的日志记录中体现 phoenix.webAPI().sleep(1000); phoenix.webAPI().closeWindow(); } return getUnitLog(); } public static void main(String[] args) { LinkedList<UnitLogBean> ll = new TestBrowserDriver().run(new CaseLogBean()); for(UnitLogBean l : ll){ System.out.println(l.getContent()); } } }
相关文章推荐
- 想听懂用户的声音,至少得先学会数据分析吧
- 一个反射型XSS例子的解析
- phoenixframe自动化测试平台的另一个实例
- 加载指定包名下的所有类或根据类的annotation进行过滤的工具类
- phoenixframe自动化平台使用多批次数据进行接口测试的示例
- phoenixframework自动化测试平台模块介绍
- PhoenixFramework自动化测试平台部署初始化说明
- 关于phoenixframe创建用例时中文乱码问题的解决方案
- phoenixframe自动化测试平台对Firefox和chrome支持的说明
- phoenixframe自动化测试平台对div弹出框(如弹出的div登陆框)的处理
- phoenixframe自动化平台使用多批次数据做接口测试的方法
- phoenixframe平台连接socket服务器,并接收返回值的示例
- 我们的技术共享微信公众号
- phoenixframework自动化测试平台1.5.0全新发布
- phoenixframework自动化测试平台环境搭建及使用
- phoenixframework驱动chrome浏览器的说明
- 关于UINavigationController自定义实效的问题,和自带效果研究
- [iOS] UICollectionView初始化滚动到中间的bug
- Android属性动画欣赏——ValueAnimator与相关博文推荐
- Android基础之UI控件