首页 文章 精选 留言 我的

精选列表

搜索[自动化测试平台],共10000篇文章
优秀的个人博客,低调大师

关于项目自动化测试架构的改良计划 - 解析XInclude标记

因为在test_suite.xml中,我们多处使用了XInclude标记,他们会被申明在一个叫"http://www.w3.org/2001/XInclude"的名字空间中,并且引入部分用xi:include来声明,我们这个类的作用就是把这些所有的<xi:include>的部分,都用被引入的文件插入和替换掉。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 /** * This class will handle converting a xinclude+xpointer marked xml file to a normal xml file * Because of the shortage of the current jdk ,it only support the xPointer with element instead of NCName *@author cwang58 *@created date: Jun 10, 2013 */ public class XIncludeConverter { /** * this method will handle change the XInclude+XPointer marked xml as normal xml * @param origialXML the original xml which has the xInclude feature * @return the parsedXML without the xInclude feature */ public static String convertXInclude2NormalXML(String originalXML) throws SAXException,ParserConfigurationException,TransformerConfigurationException,IOException,TransformerException{ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); //open up the namespace aware so that it can recognize the "xi" namespace factory.setNamespaceAware( true ); //let this SAXParser support XInclude factory.setXIncludeAware( true ); //factory.setValidating(true); //ignore all the comments added in the source document factory.setIgnoringComments( true ); DocumentBuilder docBuilder = factory.newDocumentBuilder(); Document doc = docBuilder.parse( new InputSource( new ByteArrayInputStream(originalXML.getBytes( "utf-8" )))); Transformer transformer = TransformerFactory.newInstance().newTransformer(); //format the output xml string so it support indent and more readable transformer.setOutputProperty(OutputKeys.INDENT, "yes" ); //initialize StreamResult with File object to save to file StreamResult result = new StreamResult( new StringWriter()); DOMSource source = new DOMSource(doc); transformer.transform(source, result); return result.getWriter().toString(); } 这里讲一个小插曲,其实,W3C中,XInclude经常和Xpointer联合起来应用的,xpointer可以帮助来定位目标文件的某个小片段而不是整个目标文件,定位方法可以用element(),或者xpointer(),如果element的话,可以用(/1/2/3)这种方式来定位DOM,或者基于 id,对应java的解析框架是xerce,但是非常不幸运的是,最新版本的xerce框架只支持element(/1/3/4/5)这种定位,而对于基于schema-id的方式,也就是某个element声明了id的情况,它没办法定位,但是未来可能会支持这个功能。 http://xerces.apache.org/xerces2-j/faq-xinclude.html#faq-8 基于上述的局限性,我决定只采用xi:include来包含全部文件,然后局部调整的做法,并且绕过xpointer。 所以实现代码如上所示,事实上从JDK 1.6开始,他已经提供了对XInclude的支持,内部是委托给xerce来实现的,这是对应架构图的第3-4步骤。 本文转自 charles_wang888 51CTO博客,原文链接:http://blog.51cto.com/supercharles888/1221731,如需转载请自行联系原作者

优秀的个人博客,低调大师

关于项目自动化测试架构的改良计划 - 去除动作指令

因为我们在test_suite.xml中定义了多个动作指令,比如<add_elements>,<update_elements>等,他们指示让我们Engine来对最终数据进行操作,这些动作指令不是数据,因此,他们并不包含在我们最终的数据结果集中,所以我们必须对他们进行移除。所以我们用以下代码来进行移除工作: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 public class XMLManipulator { public static String removeModifyConfFromXML(String xmlString) throws Exception{ Document doc = null ; doc = DocumentHelper.parseText(xmlString); //remove the <add_elements> from the target xml List<Node> addPart = doc.selectNodes( "/test_suite/test_case/add_elements" ); for (Node node: addPart){ node.getParent().remove(node); } //remove the <add_elements> from the target xml List<Node> updatePart = doc.selectNodes( "/test_suite/test_case/update_elements" ); for (Node node: updatePart){ node.getParent().remove(node); } //remove the <remove_elements> from the target xml List<Node> removePart = doc.selectNodes( "/test_suite/test_case/remove_elements" ); for (Node node: removePart){ node.getParent().remove(node); } //find document again return doc.asXML(); } .. } 这样最终的xml文件就不包含这些动作指令的代码片段了。 本文转自 charles_wang888 51CTO博客,原文链接:http://blog.51cto.com/supercharles888/1221739,如需转载请自行联系原作者

优秀的个人博客,低调大师

腾讯Android自动化测试实战3.3.1 控件ID相同时获取控件

3.3 Robotium实践运用 3.3.1 控件ID相同时获取控件 实际界面中常常有一些子控件是相同ID甚至没有ID的,但这时候一般其父视图是有ID的。如图3-14所示,每个TAB的控件ID是相同的。 图3-14 拥有相同ID的底部TAB 因为界面中也很可能会出现多个发现、游戏这样的文本,因此也不能采取类似getText(“发现”)这样的方式。这里,我们就可以通过ID获取唯一父控件,再通过过滤方式获取指定的控件。 //先根据ID获得唯一的布局LinearLayout LinearLayout mTabs = (LinearLayout)solo.getView("main_tabs"); //然后通过过滤方式获取该LinearLayout下的所有文本控件 ArrayList<TextView> tabs = solo

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册