WEB UI自动化之旅(三)

上一篇 / 下一篇  2009-12-16 21:09:39 / 个人分类:自动化测试

对于RIA的测试,也就是对WEB APPLICATION的富程序端的测试,Flex的测试,是自动化测试中的一个难点,由于其中HTNL与AS的转换,AMF协议的解析使得在开源的世界中实现的机制比较上,这里简单介绍下Selenium对Flex的自动化测试支持。1、Download and install Selenium RC
2、Download SeleniumFlexAPI, and rebuild yourFlexapplication with SeleniumFlexAPI.swc最主要的就是要重新编译你的swf文件,并加入相应的swc文件。
地址:http://sourceforge.net/projects/seleniumflexapi/files/下载SeleniumFlex-API_0.2.5.zip,将里面的SeleniumFlexAPI.swc文件编译到你的flex应用中!
3、Download FlashSelenium and add to your test project 
                   flash-selenium.jar加入到项目中
4、Download FlexUISelenium  and add to your test project 
地址 :http://flex-ui-selenium.googlecode.com/files/flex-ui-selenium-0.1.1.jar flex-ui-selenium-0.1.1.jar加入到项目中
5、Write and run your test cases against yourFlexapplications


测试代码如下:
public class FlexUISeleniumTest {
        private final static String BASE_URL = "http://www.geocities.com/";
        private final static String PAGE = "paulocaroli/flash/sum.html";
        private Selenium selenium;
        private FlexUISelenium flexUITester;
       
        @Before
        public void setUp() throws Exception {
                selenium = new DefaultSelenium("localhost", 4444, "*iexplore",BASE_URL);
                selenium.start();
                selenium.open(PAGE);
                flexUITester = new FlexUISelenium(selenium, "compareSumFlexObjId");
        }

        @After
        public void tearDown() throws Exception {
                selenium.stop();
        }

        @Test
        public void verifyFlexAppSumIsCorrect() {
                flexUITester.type("2").at("arg1");
                flexUITester.type("3").at("arg2");
                flexUITester.click("submit");
                assertEquals("5", flexUITester.readFrom("result"));            
        }
}

这样就可以实现对Flex的测试。

对于喜欢IDE的人来说就不那么容易了,可以将额外的支持FLEX的extension.js加入IDE的中,但是由于现在还未完全开发,selenium的官网的解释是由于纯JS的程序对FLEX的操作比较困难,正在考虑新的开发手段。这里我们能用IDE做的是首先不能自动产生代码,因为对对象的识别不能做到,您可以选在在选项中的HTML语言,然后再Table中结合FELXSPY识别然后产生代码。横向比较了FELXMONKEY1.0,SELENIUM-FLEX,RUBY+FUNFX中,都需要FLEXSPY的支持对对象的识别,都需要在编译时加入解析类和特定类,到目前为止RUBY+FUNFX的能力是比较好的,在执行时还能结合相应的watir经验使自动化更加完美。


TAG: Ruby Selenium selenium Flex自动化 ruby FunFX

 

评分:0

我来说两句

日历

« 2024-04-18  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 147573
  • 日志数: 22
  • 建立时间: 2009-10-14
  • 更新时间: 2010-07-27

RSS订阅

Open Toolbar