Tuesday, December 4, 2007

Some problems and solutions when using FunFX

Hi everyone.

These past days I have used some time trying to set up FunFX for the project I am on at work. I have said to my self earlier (because some people have had some problems with custom components) that I would write a post about this. Because I do no know to much about this area, how FunXF actually handles, I have not had the time to do this yet, but I asure you that it will come.

So instead I will use this post to talk about some of the problems and solutions I have had the last few days.

First of all double clicking a row in a datagrid made me a bit frustrated today, because it would not replay the action that I wanted to do. The following line was what I tried to do (the datagrid contained a row with a column that held the value "Person".

@ie.data_grid("name").double_click(:item_renderer => "Person")

After some error checking it seems that you must select the row before doing a double click. The following lines works perfect. I have not yet found a good reason why this behavior or a better solution if people think it should be handled better.

@ie.data_grid("name").select(:item_renderer => "Person")
@ie.data_grid("name").double_click(:item_renderer => "Person")


Anther thing I has some trouble with was accessing elements of an repeater when there is an hierarchy of display objects within the repeater, then the number of the single element I wanted waas multiplied with the number of parents abow. In the following example I would get 4 tLabels and 4 tData.

<mx:repeater id="rep" dataprovider="{}">
<mx:vbox id="vboxen">
<mx:hbox id="hboxen">
<mx:textinput id="tLabel" text="{rep.currentItem.label}"/>
<mx:textinput id="tData" text="{rep.currentItem.data}"/>
</mx:hbox>
</mx:vbox>
</mx:repeater>

I am still testing the solution (and will probably put out a new version of FunFX in the next days), so I am not completely sure that it is the best solution. But I have up until now used the objects automationChildren when try to reach the children, but this seems to multiply children of repeaters and like. So I have switched to used the rgular children instead, and for now it seems to do the trick, but I still have to test that all other displayobjects still are supported.

With the new solution the issue where you had to write the repeater and then the object you wanted is now gone. Now the repeater will not exist as an display obejct. So you write as the last bulk says.

@ie.repeater("rep").text_area("tLabel")[0].input(:text => "Test") # This is now wrong


@ie.text_area("tLabel")[0].input(:text => "Test") # This is correct


But so far I am able to do automatic functional testing of a registration form and to ensure that the calculation response from this registration is correct. Due to low speed these tests are not run too often, but I will try later to include the tests in the nightly build.

24 comments:

Bindiya Mansharamani said...

Thanks for the insight Peter. There are some more problems which i thought you would know the answers to. They are:
1) I have a datagrid which has an image as an item renderer. The image is invisible to start with but when u click on the column the image (alpha =1) is set to visible. Now i want to test this and I dont know how to access the particular cell. I can select the row using the text string but i am having a problem clicking the next column with the image on it.
2) I also wanted to know the syntax for item_edit_begin.
3) the tabular data comparison in your tests always returns a nil for me. I dont know why?
4)I also tried to work with a datagrid with showHeaders = false. It did not work for me. Would you let me know why?

Bindiya Mansharamani said...

Hey Peter,

I had some more questions/doubts:
1) I am working with a tab navigator and I dont know how to switch between the tabs. I used the related object property but that always fails.
2)I have an alert button that pops up everytime you press a button in the application. So when i write the tests i do not know how to click on it so as to make it disappear using FunFX.
3)What do I do to make the tests call the stretch column event in a data grid?
4) I have a Title Window that pops up and after making a selection needs to close. What method/event does this in FunFX?

I know these are too many questions but i am getting stuck on every component it seems. Thank you for you help in advance.

Peter Motzfeldt said...

Hi

The first one with the datagrid and the image I don't think it supports yet, but it is great that you bring up these questions, because then I get some info on what to implement next.

With editing datagrid, I will have to check it out, I don't recall how to do it. But I think you need to know the row and column index.

Strange about the tabular_data stuff, it always returns nil? Have you tried to to the following with an datagrid you now contains an item, @ie.data_grid("name").tabular_data(:start => 0, :end => 0)?

With a tab navigator you will use the text on the tab to choose the tab you want.

With the alert box, you write thefollowing:

@ie.alert("title-of-alert-box).button("label-of-button-you-want-to-push").click

You will have to implement the close function of the title window on some button or anything else that you can interact with.

Hope this helps, I will try to build some bigger applicatio that will demonstrate all of these soon.

Glad you still try it, gives me alot of info of improvements and what works.

Thanks!

Bindiya Mansharamani said...

hey Peter,
Thanks for replying.
Strange about the tabular_data stuff, it always returns nil? Have you tried to to the following with an datagrid you now contains an item, @ie.data_grid("name").tabular_data(:start => 0, :end => 0)?

I tried every permutation and combination to make it work but now i have given up. I guess it is because the data provider is an array and when i say @ie.data_grid("name").select(:item_renderer => "123456") although it selects the row it cant access its contents.

2)Thanks for the info on the tab navigator. It works now, but i have a datagrid on that page and I cant access the data in the data grid. It gives me a flex error so i am not completely sure if it is funFx or Flex.

Bindiya Mansharamani said...
This comment has been removed by the author.
Bindiya Mansharamani said...

Hey Peter,
I tried to implement the Alert thing you told me and it gives me the following error:
1) Error:
test_data_change(TestDataGrid):
NoMethodError: undefined method `button' for nil:NilClass
C:/ruby/workspace/ControlsTest/TestDataGrid.rb:23:in `test_data_change'

This is what i wrote in the ruby script:
@ie.alert("Message").button("OK").click

The corresponding mxml code is:
dataGrid2.dataProvider = array2 Alert.okLabel = "OK"; Alert.show("Data Grid has 2nd dataset");

Please help.

Thanks
Bindiya

Peter Motzfeldt said...

Hi

You will need to give the alert box an title or header, it is this name the @ie.alert("name") will use.

For example:

Alert.show("Hello World!", "Message"), where @ie.alert("Message").button("OK").click will clik the button.

Or:

Alert.show("Do you want to save your changes?", "Save Changes", 3, this, alertClickHandler), which will be an alert with a yes or no button. And clicking the No button would be done like this:
@ie.alert("Save Changes").button("No").click

Hopes this helps!

Neil Curzon said...

Thanks for this information. It seems that there's a pretty good sized community for FunFX. Is there a mailing list somewhere? If not, it may be a good idea to start one.

Bindiya Mansharamani said...

This sure helps. I do the same thing in FLEX, just didnt know I could do it in FunFX as well.


Thanks Peter!!

Peter Motzfeldt said...

Hi Neil

I was not sure were to add FunFX as a project, but ended up with Rubyforge, so at http://rubyforge.org/projects/funfx/ there is both a developer mailing list and a user list.

Please use them, but by all means put what ever you like on this blog to :-)

Unknown said...
This comment has been removed by the author.
Unknown said...

Hi, Peter

I have just learned about FunFX. Nice project. It is good to see someone else is also working on Flex automation issue.

If anyone is interrested I am working on my own test automation tool for Flex. More details here http://riatest.com

TN.

Peter Motzfeldt said...

Hi T

Nice!

Is it an open source project? If so I would be very exciting to see what you have done.

There's a lot of issues I have not yet been able to solve on a nice way (without tape and big nails :-), and it would be nice to share some thoughts and solutions.

- Peter

Bindiya Mansharamani said...
This comment has been removed by the author.
Neil Curzon said...

Hi Peter/All. I'm having some issues finding children of FormItems. It seems that when my Button is inside a form item, I can't find it. I can successfully find every element by id up to and including the form item, though.

irb> ie.button("NOT_EXISTING")
=> nil
irb> ie.form_item("frmItem")
=> (messy item description, not nil)
irb> ie.form_item("frmItem").button("NOT_EXISTING")
NoMethodError: private method `split' called for nil:NilClass
from c:/tools/ruby186/lib/ruby/gems/1.8/gems/FunFX-0.0.2/lib/flex.rb:32: in `method_missing'
from (irb):16

I get the same behavior when I use the correct Button id.

I think this is because an exception is being thrown from the flex side. (I will try to debug the actionscript side tomorrow).

Any help would be greatly appreciated!

Neil Curzon said...

Ok, I've got a workaround, but there's still weird things going on. The mx.automation.delegates.containers.FormItemAutomationImpl seems to not work if you're trying to retrieve a FormItem from a Form that has ANY FormItems with no label. You must set every label of every form item in the Form you're working with to a NON EMPTY string. Unfortunately, this affects formatting, even when your label is just whitespace. You can workaround this by setting labelWidth="0". After adding label=" " labelWidth="0" to each FormItem (note that label is a space, not empty) I could successfully find and interact with items inside it without breaking formatting.

Peter Motzfeldt said...

Hi Neil

Thanks for the notice. Seems to be a problem here yes. I think this issue should be fixed, due to the fact that forms is used extensively. It should be possible to use a form item without setting the labelwidth.

I have never noticed this before.

I will see if I can sort this out.

This information is valuable to me, thanks!

Peter Motzfeldt said...

Hi Neil

Have checked out the error with the form item.

I am using a method from the automation framework from Adobe, which creates an ID of the object at hand. It is this method that generates the error. The method is getItemAutomationName in the FormItemAutomationImpl.as class. It tries to access the klabel and then create the id, but since the label is not set it returns a nullpointer exception.

I have not yet been able to test if this can easily be fixed by cheking if the label is not null. But this will probably implie changes in the way it resolves the object from the created id as well.

Maybe we just have to use your workaround. I will write a short text about this, thank you very much for the tip!

Unknown said...

Hi Peter!

I really liked the FunFX project. It is great to see some automation effort for Flex applications.

I had a couple of questions about FunFX. I would really appreciate any help you can extend.

1. Does FunFX work on 64-bit platforms?
2. Is FunFX Unicode-friendly? Can it be used to test languages other than English (French, German, Japanese)?


Thanks in advance!

Peter Motzfeldt said...

Hi Apurva

Sorry about the late response, I have had a surgery on my shoulder.

With the 64 bit, I am honestly not sure. I have not done anything to support it. I have not developed anything for 64 bit before.

With support for special charachters the answer is yes and no. It recognize norwegian special chars lik æ,ø and å. But it recognize them as \346, \370 and \345.

But you can interact with components having special charachters intheir id as usual.
@ie.label("tLabelæøå").

Hope this answers your questions.


(I have also answered the mail)

Asher said...
This comment has been removed by the author.
Unknown said...

4) I have a Title Window that pops up and after making a selection needs to close. What method/event does this in FunFX?

This question was previously asked by bindiya and u replied.
"You will have to implement the close function of the title window on some button or anything else that you can interact with."

Is there a way to close the Title Window by invoking the flex events such as the one specified in your Date chooser example:
@ie.date_field("dateField").open(:trigger_event => "flash.events::MouseEvent")

Similarly one can:
#@ie.title_window('conferenceAddMemberPopup').open(:trigger_event => "titleWindow.mx_internal::closeButton")
#@ie.title_window('conferenceAddMemberPopup').open(:trigger_event => "flash.events::CloseEvent('close')")

I tried all the above options and all of them seem to fail.

Please help me if possible in this regard

Thanks,
Harshad

FunFXLerner said...

hi,
I am using FunFX. Problem is how to get all the values in Combobox using FunFX. I need to print all the Text values in Combo box.
can anyone help me....
thanks
eclipse

Alita said...

Hi,
I am trying to run an application but I got the following error
/home/alejandra/workspace/WorkGroupTest/work_group_test.rb:2:in `require': no such file to load -- funfx (LoadError)
from /home/alejandra/workspace/WorkGroupTest/work_group_test.rb:2

I want to do a sample to test Flex application.

Eclipse SDK 3.3.2

Alejandra A