Sunday, May 17, 2009

FlexUISelenium for testing Flex UI with Selenium

Due to the high number of requests for making FlashSelenium directly test the UI components of a Flex application, I got involved in a new open source project: flex-ui-selenium. The new component, FlexUISelenium, is used with Selenium RC for testing Flex UI interactions.

FlexUISelenium is an extension to the Selenium RC client driver that enables the Selenium RC client drivers to interact (and test) the Flex UI components and methods of the Flex application.

Here is a sample test code using FlexUISelenium:


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


FlexUISelenium uses Selenium RC, Flash Selenium and Selenium Flex API. FlexUISelenium uses FlashSelenium for enabling the communication of Selenium RC client with the Flash application (swf). And Selenium Flex API exposes all the UI components of the Flex application which are built with SeleniumFlexAPI.swc.

The first public release has just been uploaded to the project page.

Enjoy it!

15 comments:

manoperez (@ivanrodolfo) said...

It's very nice! I will try it as soon as I can

John Waggener said...

At:

http://code.google.com/p/flash-selenium/

'IMPORTANT: FlashSelenium is unstable with Selenium RC 1.0. I am currently working on a fix. All was good until Selenium RC version 0.9.2...'

So I downloaded Selenium RC .9.

I could not get the example clickcolors to run.

It seemed to refer to
http://code.google.com/p/flash-selenium/issues/detail?id=1

interpreting the browser as IE.

This looks like a great project and I would love to use Selenium to automate testing of my projects. Is it correct to say that if I cannot get flash selenium to work then FlexUISelenium will not work for me? Thanks.

Sachin said...

Hey John,

We're facing some compatibility issue with Flash Selenium with RC 1.0 and are looking into it. Considering the large user base of Flash Selenium, we're sorry that we aren't constantly polishing Flash Selenium. We'll make sure we fix the issue in couple of weeks.

Thanks and we appreciate your feedback.

raj said...

Hi,

I tried to run the FlexUISelenium sample "FlexUISeleniumTest.java" but i get the below error. I even tried to point the app to my local instance, but i get the same error.

I am using Selenium RC 1.0. Is this due to teh open issue with Selenium RC 1.0 and FlashSelenium?

Can you please help me?

Thanks
Raj

com.thoughtworks.selenium.SeleniumException: ERROR: Threw an exception: 'window.document.compareSumFlexObjId' is null or not an object
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:73)
at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:154)
at com.thoughtworks.selenium.DefaultSelenium.getEval(DefaultSelenium.java:334)
at com.thoughtworks.selenium.FlashSelenium.call(FlashSelenium.java:55)
at com.thoughtworks.selenium.FlashSelenium.PercentLoaded(FlashSelenium.java:95)
at com.thoughtworks.selenium.FlexUISelenium.waitUntilLoaded(FlexUISelenium.java:26)
at com.thomson.tssq.j2012.test.FlexUISeleniumTest.setUp(FlexUISeleniumTest.java:33)
at

Unknown said...

Thanks for your help. It was great to be able to automate a test for my simple flex apps. But I want to test the more advanced applications now. It can be seen here how to type and click in the Flex app through the selenium testing. But where can we find more information on what else we can do and how to do it, select a value from a selection box or read data from an advanced data grid for example?

Unknown said...

Hi all, I've been testing flex apps successfully thanks to Flex UI, but was have hit a hurdle.

I need to test an app using either *chrome or *firefox, but the version I use at the moment only responds to *firefoxproxy.

Has anyone got Flex testing working through firefox by using the *firefox/*chrome commands only, and if so, what set up (version of firefox etc.) have you got?

Much appreciated,
Phil

Sachin said...

@Phil

FlexUISelenium with Selenium RC 0.92 would work well on Firefox 3.0.x. It was our initial platform when we first started this project during which *chrome/*firefox worked without any problem.

Sandeep.S.N said...

Is it possible to make Flex UI Selenium identify a component by its automation name, name etc...

Currently I observed that it only identifies label and ids.

Chaudhry Adnan Riaz. said...

Hi,

I am new to Flex automation, Adobe says here that To use Flex Automated Testing, you must install Flex Builder 3 Professional. You cannot use Flex Automated Testing with only the Flex 3 SDK. If you do not have a Flex Builder Professional license, your test scripts are limited to 30 actions. If you exceed 30 actions in a test without the Professional license, you will receive a warning that your license is not present.

is this case true for FlexSelenium? can anybody please tell me what licenses do I need to have to automate Flex applications in Selenium?

Thanks.

Sachin said...

@Sandeep

I'm afraid that Flex-UI-Selenium doesn't identify the entire set of UI components that Flex offers. This is partly to be blamed on the fact that Paulo's back in Brazil and me being busy this year.

We are looking for contributors who would like to take this forward and if you wish to contribute (or) know someone who wishes to, please drop me a mail and we'll make it happen. :)

Thanks.

Sachin said...

@Chaudhry

You don't need to pay a cent to use FlexUISelenium/FlashSelenium dude. Selenium and its drivers (and) Flash Selenium are under Apache 2.0 License.

But, if you need to modify the flash application which "might" have been developed using Flex Builder, then you should get the appropriate license from Adobe.

I'm not quite sure, but I guess Adobe requires you to buy Flex Builder license to use their Flex Automation library. Again, not sure about this, so you might want to get a second opinion on this.

Chaudhry Adnan Riaz. said...

Hi,

I found this article on Flex Builder License and Automation. It says We need to have a valid professional version of Flex Builder at the time of application compilation to get the complete functionality of automation.

@Sachin: You mentioned you guys were looking for contributors, Can I help? :)

Thanks.

Eusebiu Blindu said...

Hi,

Its great that people try stuff but I wouldn't use selenium flash to test anything for now.
Read my blog about this here:
http://www.testalways.com/?p=63

You can correct me if I am wrong.

Thanks,
Sebi

$$gOlu$$ said...

Hi,

I have tried to automate the calculateSum application and it is working fine for me but when I am trying to automate my application i am getting a below exception

"com.thoughtworks.selenium.SeleniumException: ERROR: Threw an exception: 'window.document.admin' is null or not an object"

for creating the agent i am passing the selenium object and the name of the swf file .

flexApp = new FlexUISelenium(selenium,"admin");

after this if i will do any operation with flexApp object i am getting above exception .

Please help

Thanks
Roopesh

Sushma Narla said...

I want to automate drag and drop in my flex applicaiton and iam trying to use function doFlexDragTo.

Please can any one help me to understand how to use it