selenium support for flex

Steps:
      1. Download and install Selenium RC
      2. Download Selenium Flex API, and rebuild your Flex application with SeleniumFlexAPI.swc (The most important thing is to recompile your swf file and add the corresponding swc file.)
            Address: http: //sourceforge.net/projects/seleniumflexapi/files/ Download SeleniumFlex-API_0.2.5.zip and compile the SeleniumFlexAPI.swc file inside into your flex application!
      3. Download FlashSelenium and add to your test project 
                    flash-selenium.jar is added to the project
      4. Download FlexUISelenium and add to your test project 
                   Address: http://flex-ui-selenium.googlecode.com/files/flex-ui -selenium-0.1.1.jar flex-ui-selenium-0.1.1.jar is added to the project
      5. Write and run your test cases against your Flex applications


test code is as follows:
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"));            
        }
       
}









Tried the piece of code posted by the landlord, but the progress was not very smooth, it took some time to finally get it done, so let's write some Comments, hope it helps others.

public class FlexUISeleniumTest {
        private final static String BASE_URL = "http://www.geocities.com/";
        private final static String PAGE = "paulocaroli/flash/sum.html";

        private FlexUISelenium flexUITester;
       //First of all, the url given above has expired, and there is no way to use it. The solution is to use your own url, but your project must be compiled with
        sfapi.swc @Before
        public void setUp() throws Exception {
                selenium = new DefaultSelenium("localhost", 4444, "*iexplore",BASE_URL );
//Note that if you use firefox here, there will be a bug, the solution is to use "*firefoxproxy" instead of "*firefox"
                selenium.start();
                selenium.open(PAGE);
                flexUITester = new FlexUISelenium(selenium, " compareSumFlexObjId");
// use your flashObjectId to compareSumFlexObjId here, you can find it by checking your HTML
        }

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

        @Test
        public void verifyFlexAppSumIsCorrect() {
                flexUITester.type("2").at("arg1");
                flexUITester.type("3").at("arg2");
                flexUITester.click("submit");
//The arg1, arg2 and submit used here are UI ID or name. If your project is compiled correctly,
                assertEquals("5", flexUITester.readFrom("result")) will be displayed when the mouse hovers;           
        }
}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326759594&siteId=291194637