Thursday, November 22, 2007

FunFX - How to write tests

The last post talked about howto get started and how to make the Flex application ready for testing. I am sorry about the time it took me to post this sequel.

FunFX is a framework that is composed of two parts, one adapter (the last post talked about this part) that enables the Flex application to be tested, and one Ruby framework that enables you to drive an Internet Explorer instance with the Flex application.

Some people ask me if there is an easy way to implement support for either FireFox or other browsers, and the answer to this is both yes and no. It depends, there are currently only IE that is implemented and the reason for this is IE's support for COM objects. I will explain this implementation in a bit more detail in another post.

This post will talk about the Ruby framework mentioned in the beginning. This Ruby framework is a Ruby gem. This framework creates an instance of a Internet Explorer window. Then with some initializing methods you will direct the IE window to the address of the Flex application.
This is shown in the follwoing table. The first sentance creates an instance of FunFX. When executing the second line with the start method FunFX creates an instance of IE in the background with the help of Win32OLE. The argument tells FunFX if you want the IE to be visible or not.

@ie = Funfx.instance
@ie.start(true)
@ie.speed = 1
@ie.goto("http://localhost/flexapplication.html", "flexapplication")


The last sentance in the initialization is the method that directs the browser to the Flex application and hooks on to the actual Flex object with the help from Win32OLE, and the name of the swf file. If you have an html file named index.html that contains a swf file that is named flexApp.swf and is located at http://localhost/flexapplication/index.html. The

@ie.goto("http://localhost/flexapplication/index.html", "flexApp")


After this initialization, the @ie variable (which is an instance of FunFX) is ready to interact with the Flex application.

The FunFX in itself does not test Flex applications in the sence of asserts, it just enables you to drive an Flex application programmatically and get the state and text of all display objects. To make assertions and create test scripts you will need to use FunFX together with a testing framework of your choice. A couple of examples are RSpec, and Test::Unit. FunFX together with any of these tools make up an automated functional testing tool.

Before I will show you an example of FunFX together with these tools, I will explain in short how to use FunFX in the sence of driving the Flex application programmatically.

A Flex application is built as an hierarchy of different display objects, with the Application object as the root node. With FunFX you can think of @ie the root node of the Application object.

An example of interacting with a display object is shown in the box below.

@ie.button("buttonName").click

This line of code will click the button with id or label named "buttonName". This button can be located anywhere in the Flex hierarchy. In version 0.0.1 FunFX only supported single elements, and then it stopped when it found a object matching this signature. But this was a problem with repeaters, which creates children with the same id's.

So in 0.0.2 it finds all objects that matches that type and name, and delivers them as an array, as shown below:

@ie.button("buttonName")[0].click

To interact with a display obejct you must provide the label or id.

Some flex event needs arguments as when inserting text into a textbox. This is done as follows:

@ie.text_area("price").input(:text => "This is the new text")


@ie.data_grid("gridName").drag_start(:dragged_item => "Name of item")
@ie.data_grid("gridName").drag_drop


There are many more methods. Unfortunately there are no good overview of all the methods and their arguments. But you should look at the AutomationGenericEnv.xml, which describes all the display object types and their events and arguments.

When testing the functionality of an application it does not help being just able to drive the application. It must be possible to extract some information to assert with a testing tool such as RSpec or Test::Unit.

You can get information about alot of thing, such as visibility, text, rows in a datagrid, enabled etc. These are called properties and are also described in the AutomationGenericEnv.xml.

The following displays some examples of extracting data. It is possible to extract the selected index of an data grid, making it possible to extract information about that grid line with the tabular_data property. This creates a comma separated string containing the row information. If there are images in the row, the name of the images will be displayed.

pos = @ie.data_grid("gridName").selected_index
@ie.data_grid("gridName").tabular_data(:start => pos)

@ie.label("labelName").text
@ie.application("applicationName").current_state

I have not yet tried how this works with the new upgraded grid in Flex 3.

The following is an example test that tests an flex application that adds a product to a datagrid with the use of an popup window. This test is test nr 1 at the bottom of this post.

require 'test/unit'
require 'funfx'

class TestProductOne <>

def setup
@ie = Funfx.instance
@ie.start(true)
@ie.speed = 1
@ie.goto("http://funfx.rubyforge.org/Flex/FlexRepeater.html", "FlexRepeater")
end

def teardown
@ie.unload
end

def test_insert_product

assert_equal(0, @ie.data_grid("dgOffer").num_rows)

add_product("Shirt", "Tennis")
@ie.button("bOk").click

assert_equal(1, @ie.data_grid("dgOffer").num_rows)

end

def add_product(name, category)
@ie.button("bAddProduct").click

@ie.text_area("tName").input(:text => name)
@ie.text_area("tCategory").input(:text => category)
end
end


This post is a bit messy, but i tries to explain some of the basic elements. The following post will try to explain other concepts in more detail.

I have put out an test application that set up for testing with a couple of simple actions to perform at TestApplication. At the following links I have also written a couple of tests that test this application. Please try them out and alter them to see if you get it going (the source code of the view files are available at view source, or this address source-code).
I hope this test application and test scripts help you to get going.

55 comments:

Eduardo Mendez said...

Hi Peter,

I'm testing your API and I'm finding a problem with a custom component. It's the fisheye component from Ely Greenfield: http://www.quietlyscheming.com/blog/components/ fisheye-component. It has a property "selectedIndex" that, when set, changes the selection to the item desired:

[Bindable("change")]
public function get selectedIndex():int
{
return (isNaN(selectedItemIndex)? -1:selectedItemIndex);
}
public function set selectedIndex(value:int):void
{
var v:Number = (value < 0 || value >= _items.length)? NaN:value;
if(v != selectedItemIndex)
{
selectedItemIndex = v;
updateState();
animator.invalidateLayout();
dispatchEvent(new Event("change"));
}
}

I am modifying AutomationGenericEnv.xml to add this component:

[ClassInfo Name="Fisheye" Extends="Object"]
[Implementation Class="qs.controls::Fisheye"/]
[Events]
[/Events]
[Properties]
[Property Name="selectedIndex" ForDescription="true" ForVerification="true" ForDefaultVerification="true"][PropertyType Type="Number"/][/Property]
[/Properties]
[/ClassInfo]

But, when I tried to incorporate that in a test:

puts @ie.image("trebol").source # this works fine
puts @ie.fisheye("fisheye").selectedIndex # this raises an error

I got this:

C:\TestsRubyPrueba>saint_test.rb
Loaded suite C:/TestsRubyPrueba/saint_test
Started
#[WIN32OLE:0x34ad53c]
E
Finished in 19.338 seconds.

1) Error:
test_saint_login(SaintTest):
NameError: uninitialized constant Flex::Fisheye
c:/ruby/lib/ruby/gems/1.8/gems/FunFX-0.0.2/lib/flex.rb:35:in `const_get'
c:/ruby/lib/ruby/gems/1.8/gems/FunFX-0.0.2/lib/flex.rb:35:in `method_missing
'
C:/Archivos de programa/eclipse-3.2.2-saint7/workspace/TestsRubyPrueba/saint
_test.rb:30:in `test_saint_login'

1 tests, 0 assertions, 0 failures, 1 errors


The form in which the component is included is this:

[mx:Image id="trebol" blendMode="layer" alpha="0" source="@Embed(source='/assets/logo.png')"/]

[mx:VBox width="100%" top="0" verticalGap="0" ]

[qs:Fisheye id="fisheye" width="100%" height="95"
dataProvider="{opciones.lastResult.opciones.opcion}"
stateProperty="currentState"
defaultValue="" rolloverValue="hilighted" selectedValue="selected"
showEffect="Zoom"
change="seleccionarOpcion(event)"

verticalAlign="bottom"
horizontalAlign="center"
animationSpeed=".1"
defaultScale=".7"
defaultSpacing="5"
hilightSpacing="4"
hilightMaxScale="1"
hilightScaleRadius="4"
hilightScaleSlope=".6"]

[/qs:Fisheye]
[/mx:VBox]

Any suggestion?. Something to do with the "qs" namespace? or with the Box?. Any idea?.

Congratulations for this nice fw and thanks in advance,


Pepe.

Peter Motzfeldt said...

I am sorry for the late response. The main reason why you get this error is because at this point you will need to build a new gem with the modified automationGenrivEnv.xml file.

I was not able to find a smart solution where both the Flex project and the FunFX framework would use the same AutomationGenricEnv.xml file.

This is something I will need to support later.

I have not been able to try what you are trying to do. But I will try to build a custom component and put out a post about how to do this. Please give me some pointers if you get it right.

John said...

Very impressive! I'm a member of the Philips QA Team and we are going to use this to test the Flex functionality of consumer.philips.com.
We will use this together with Watir for the non-flex parts. Do you know if there is documentation about the object syntax (like radio buttons, checkboxes etc.)? Because it is different from Watir, e.g. 'radio' in Watir and 'radio_button' in FunFX.

Eduardo Mendez said...

Works nicely. Thanks.

Bindiya said...

I tried the example from you video, the WorkGroupTest and it somehow is not working for me. I keep getting errors soon after creating a blank FLEX application. When I build it, I get the following error:
Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: AutomationGenericEnv.xml

The other time I got the following
Error #2060: Security sandbox violation: ExternalInterface caller file:X.swf cannot access file://Y.html

Please let me know where I am going wrong.

Thanks
BRamani

Peter Motzfeldt said...

It is nice that people like it, even though it is still an early edition. But this makes it fun to improve it.

About the object syntax John, the entire class hierarchy in Ruby is created dynamically in memory from the AutomationGenericEnv.xml, and the names in this xml file for instance DataGrid kan be written both @ie.DataGrid("name") and @ie.data_grid("name"), when a method is called the framework renames the Ruby way of writing names to the Flex way of writing names. So just look at that file. But your are right I should create something better that people can look at. I will see if I can create something, because there are also some special method I have created in Ruby (these are located in the xml_parser.rb file)

Thanks for trying it out!

Peter Motzfeldt said...

Hi BRamani

The first error is because you have forgot to add the AutomationGenricEnv.xml to the application, or it has not been copied to the output catalog when the application was built. Try to copy the xml file into the bin catalog or where your swf file is compiled.

The other sandbox error I am not sure what is, but keep me posted about your progress. I am glad to help you get going!

John said...

OK, so I just have to look in the XML file, great. Our website has a lot of customized object, so I suppose I have to add them to the AutomationGenericEnv.xml as well? Anyway, keep up the good work and if you need any help or testing, just let me know.

Cheers,
John

Peter Motzfeldt said...

I realized now that my answer ws not to good, but it is correct that you should look at the xml file and that alle the names in that file is possible to use. But to make it more ruby alike and more the same way as Watir i created the framework so it understands ruby syntax as DataGrid in Actionscript and Java would be data_grid in ruby. So all the names in the xml file kan be written instead of camelcase but with the same names divided by a underscore.

If you see something that needs improvements or want to improve it go right ahead and please post stuff about the framework on either the user or the developer mailing list at http://rubyforge.org/projects/funfx/
(And if you want a developer access at Rubyforge just let me know :-)

I really would like to get some feedback on usage.

If the customized objects uses special methods and events you will have to add them to the xml file and then build a new gem, but if you custom objects only inherits for example datagrid and does not use any special methods and events you just use the inherited version.

But I have not tried to use custom components to much, but I will try to write a post about thet this weekend.

And if there are something you are stuck with please let me know. The fastest way to get in tuch is with the mailing list.

- Peter

Bindiya said...

Thanks for the reply it was very helpful. Now i have another error in the same example. Thought of asking you:

1) Error:
test_work_group(WorkGroupTest):
NoMethodError: private method `select' called for nil:NilClass
C:/ruby/workspace/WorkGroupTest/WorkGroupTest.rb:27:in `test_work_group'

1 tests, 0 assertions, 0 failures, 1 errors

where line 27 is:
@grid = @ie.data_grid("dgEmployees")
@grid.select(:item_renderer => @lname)
row = @grid.selected_index
assert_equal("#@fname,#@lname,#@location", @grid.tabular_data(:start => row, :end =>row))

it also blew up on the combo box so i had to change it to a text box. the combo box kept showing locationModel.location and the test would fail everytime.

Please let me know where I am going wrong.

Thanks a lot
B Ramani

Peter Motzfeldt said...

Hi B Ramani

It seems that you do not have a datagird object in your Flex application that is called dgEmployees or the automation package does not find it. If the latter then I am not really sure. Then you must send me more of the Flex code to see what is going on.

Do you remember to write the dataprovider of the combobox as this: dataprovider="{locationModel.location}", if you do not use the brackets it will probably show the text.

Let me know if this helps or not, if not I will take a closer look at the code.

Hope you get it :-)

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

I fixed the error already :)

thanks

Peter Motzfeldt said...

Hi B Ramani

That's great, I am sorry I did not manage to answer earlier.

What was the answer?

- Peter

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

Hi Peter,

Few days ago I found FunFX and I think that is exactly what I was looking for. But during I was working with your tool I met problem which I can't manage.
In my very simple flex application I'm using custom object, Container which extends UIComponent and button object. I added ClassInfo to AutomationGenericEnv.xml:

<ClassInfo Name="CustomContainer" Extends="Object">
<Implementation Class="com.p2p.view::Container" />
<Properties>
<Property Name="width" ForVerification="true">
<PropertyType Type="int"/>
</Property>
</Properties>
</ClassInfo>


and I can get width in my test method:

puts @ie.custom_container("panelsContainer").width

But if I want to click or get label from button funFX throw error:

1) Error:
test_test1(Test3):
NoMethodError: undefined method `label' for nil:NilClass
test3.rb:20:in `test_test1'


I have no idea what is wrong :(

Below you can see my test and flex source.

require "win32ole"
require "test/unit"
require "Funfx"

class Test3 < Test::Unit::TestCase
def setup
@ie = Funfx.instance
@ie.start#(true)
#@ie.speed = 1
@ie.goto("file:///g:/Test2/bin/FunFX_Test.html", "FunFX_Test")

end

def teardown
@ie.unload
end

def test_test1
#puts @ie.custom_container("panelsContainer").width
puts @ie.button("SimpleButton").label
end
end


FunFX_Test.mxml

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="initApp();">
<mx:Script>
<![CDATA[
import com.p2p.view.Container;
public var container:Container;

public function initApp():void
{
container = new Container;
container.id = "panelsContainer";
container.width = 400;
container.height = 600;
container.x = 0;
container.y = 0;

addChild(container);
}
]]>
</mx:Script>
</mx:Application>



Couteiner.as:

package com.p2p.view
{
import mx.core.UIComponent;
import mx.controls.Button;

public class Container extends UIComponent
{
private var myButton:Button;

public function Container()
{
super();
}
override protected function createChildren():void
{
myButton = new Button();
myButton.id = "SimpleButton";
myButton.width = 200;
myButton.height = 200;
myButton.label = "Hello world!";

addChild(myButton);
}
}
}

rajan said...

Hi Peter,

Firstly, I would like to thank you for having released your peerless 'FunFX' tool as 'open-source'. Though I am totally new to your tool (had worked on another tool named Selenium with Ruby before), when I executed your sample script, I was very pleased to see it worked fine for me. But i was wondering how you got the names or properties of the controls you had referred to in your sample script and whether I can get the properties of the controls in our flash-based application, which do not have the 'View Source' option, in the same way. If you could let me know how to get the properties of various controls in a flash-based application, it would be extremely helpful.

Thanks for your time,
Rajan.

HERE IT IS said...

How you got the names or properties of the controls to write a script for performing the actions. Please let me know, which will helps me a lot.

Regards
Madan

Peter Motzfeldt said...

Hi Rajan and Madan. Sorry about the extreeeeemly late response. Do you still need the information?

rajan said...

Hi Peter,

Yes i still need the information that i had asked for earlier .

Regards

Rajan.P.K.

Peter Motzfeldt said...

If I understand you correct, you need to be able to find the names or id's of the controls. Like @ie.button("nameofbutton"), you would like to know how to get the "nameofbutton" ? Am I right?.

If so, this name is either the id of the control, which you will find in the source code, or by using FlexSpy http://code.google.com/p/fxspy/, but in both cases you need to be able to reach the code. You can also use the viable text on components, but not all components do have visual text.

Hope this helps. Let me know if you need more information.

rajan said...

Hi Peter,

Thanks a lot for the information you provided and also about Flexspy which i was not aware of earlier.Thanks

Regards

Rajan

Larry said...

Hi Peter,

I'm trying to get up and running on MacOS with FunFX. Is there anything I need to do in addition to the windows instructions? Any other gems I need?

I'm running into the following:
Although I have the gems installed I'm getting a load error with require 'funfx'. I added require 'rubygems' which resulted in a load error for rbosa. I tried to install the rbosa gem (since I figured AppleEvents might be needed for Safari?) but that led to a number of other issues. Just want to check if there somewhere documenting getting FunFX running on MacOS.

Thanks.

Larry.

Peter Motzfeldt said...

Hi Larry

I have not used FunFX on Mac, thus not sure what you need. Sorry about that. I think you should post a message on the mailing list for FunFX, I think you will reach more people that use Mac and FunFX there.

(I wish I owned a Mac, but unfortunatly I don't ;-)

banson.niu said...

Hi Peter,
I am testing a TextArea, before I input the words, there is some words already there. So I want to clear it and input new words.
I wrote the code as below:

@ie.text_area("test").SelectText(:beginIndex => 1, :endIndex => 4)

@ie.text_area("test").input(:text => "Hello")

But it meets the error as:
"IO failed: wrong argument type Symbol (expected String)."

Do you have any good suggestion about this issue?

Peter Motzfeldt said...

I am not sure if this might be the reason, but try to write it like thi:

@ie.text_area("test").select_text(:begin_index => 1, :end_index => 4)

And also notice that the index begin at 0, so if your text that is currently showing is 4 letters long, you must use 0 as begin index and 3 as end index.

Let me know if that was the reason :-)

banson.niu said...

Hi Peter,
Your solution is still fail, the error is
1) Error:
test_control(TextAreaTest):
NoMethodError: private method `gsub' called for 0:Fixnum
c:/ruby/lib/ruby/1.8/rexml/text.rb:292:in `normalize'
c:/ruby/lib/ruby/1.8/rexml/element.rb:1084:in `[]='
c:/ruby/lib/ruby/gems/1.8/gems/FunFX-0.0.4/lib/xml_parser.rb:122:in `select_
text'
c:/ruby/lib/ruby/1.8/rexml/element.rb:890:in `each'
c:/ruby/lib/ruby/1.8/rexml/xpath.rb:53:in `each'
c:/ruby/lib/ruby/1.8/rexml/element.rb:890:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/FunFX-0.0.4/lib/xml_parser.rb:120:in `select_
text'


As I check in AutomationGenericEnv.xml, there is only the "SelectText" method for text_area, no "Select_Text".

Peter Motzfeldt said...

Hi

The documentation is not very good, I am sorry about that. We are now rebuilding FunFX so it will be easier to use.

But there is a mechanisme that renames the methods from SelectText to select_text to make it more Ruby like, but it should work both ways. But the error you get noe might be because om an error in rexml. Try to add this patch: http://groups.google.com/group/ruby-talk-google/msg/29820f7a7e444265

Let me know if this made it work

nilesh said...

Hi peter,
I want to know all the data_grid methods/variables (like tabular_data, selected_index). How I can get this info??

Thanks,
Kaustubh

Peter Motzfeldt said...

Hi Kaustubh

Right now you need to read the automationGenericEnv.xml file.

We are now rewriting FunFX and with the new version, there will be an api with better readabillity. Take a look at http://github.com/peternic/funfx

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

Hi peter !
Actually i don't want to compile the application with Automation libraries and FunFXAdapter.swc for automation.

I m trying to use runtime loading...

Is dr possibility to do that?

I edited and used the runtimeloading.mxml which is in (flex_builder_install_dir/sdks/3.0.0/templates/automation-runtimeloading) directory and compiled it with Automation libraries and FunFXAdapter.swc using the Batch file.
Then i edited the runtimeloding.html.

Then i put this runtimeloading.html, runtimeloading.swf and AutomationGenericEnv.xml into the web server along with the compiled application.

And called the runtimeloading.html for accessing.

I just tried this using FlexRepeater and execute the test_product_one.rb

i got the error as
>ruby test_product_one.rb
Loaded suite test_product_one
Started
E
Finished in 11.859 seconds.

1) Error:
test_insert_product(TestProductOne):
NoMethodError: undefined method `num_rows' for nil:NilClass
test_product_one.rb:19:in `test_insert_product'

1 tests, 0 assertions, 0 failures, 1 errors
>Exit code: 1
Runtimeloading.mxml i used :
[?xml version="1.0" encoding="utf-8"?]
[mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="actionScriptFunction()" ]
[mx:Script]
[![CDATA[
import flash.external.*;


public function init():void
{
myLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
}
private function ioErrorHandler(event:IOErrorEvent):void {
trace("ioErrorHandler: " + event);
}
public function actionScriptFunction():void
{
init()

myLoader.source ="FlexRepeater.swf";
}

]]]
[/mx:Script]

[mx:SWFLoader id="myLoader" width="100%" height="100%" preinitialize="myLoader.loaderContext = new LoaderContext(false, ApplicationDomain.currentDomain)" ]
[/mx:SWFLoader]


[/mx:Application]
RuntimeLoading.html i used :
[style type="text/css"]
[!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #808080;
}
#fileLayer {
position:absolute;
width:319px;
height:30px;
z-index:1;
left: 486px;
top: 603px;
visibility: hidden;
}
--]
[/style][/head]

[body scroll="no" top="0" left="0" ]
[object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
id="app" width="100%" height="100%"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"]
[param name="movie" value="runtimeloading.swf" /]
[param name="quality" value="high" /]
[param name="bgcolor" value="#869ca7" /]
[param name="allowScriptAccess" value="sameDomain" /]
[embed src="runtimeloading.swf" quality="high" bgcolor="#869ca7"
width="100%" height="100%" name="app" align="middle"
play="true"
loop="false"
quality="high"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer"]
[/embed]
[/object]
[/body]
[/html]

Batch file i used to compile:
SET OPTS=-include-libraries+=E:\libs\FunFXAdapter.swc;E:\libs\automation.swc;E:\libs\automation_agent.swc;

..\..\bin\mxmlc.exe %OPTS% runtimeloading.mxml


One more thing when i tried to compile by creating new flex project and placing the runtimeloading.mxml in src and include the libraries in the compiler option, I got an error when loading in browser as:

SecurityError: Error #2060: Security sandbox violation: ExternalInterface caller file:///E:/RTL/bin-debug/runtimeloading.swf cannot access file:///E:/RTL/bin-debug/runtimeloading.html.
at flash.external::ExternalInterface$/_initJS()
at flash.external::ExternalInterface$/addCallback()
at src.main::FunFX()[D:\Documents and Settings\Peter Motzfeldt\Eclipse-workspace\FunFXAdapter\src\main\FunFX.as:56]
at src.main::FunFX$/init()[D:\Documents and Settings\Peter Motzfeldt\Eclipse-workspace\FunFXAdapter\src\main\FunFX.as:91]
at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::docFrameHandler()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\managers\SystemManager.as:2324]





Peter Motzfeldt said...

Hi

You are trying to use the swfloader?

I have not been using the swfloader that much, and I am not sure if this is possible to test with FunFX. Can you use FlexSpy to inspect if it is possible to insepct the elements within the loaded swf file from the main application?

If this is possible it should be possible.

Alok said...

Hi,

I was not able to find num_rows event for data grid object in the XML file.
While traversing through your sample test cases i cam acrss this:
@ie.data_grid("dgOffer").num_rows)

Can you please point me to the correct xml file to be used?

Thanks in advance

Regards

Peter Motzfeldt said...

Hi

The num_rows and tabular_data and some other methods does not exists in the xml file. These methods is added separately. Take a look in the xml_parser.rb file and the method add_tabular_method.

The documentation of all the methods, is not good, I am sorry about that. This will be better inn the 0.2.0 version.

Hope it helped!

Alok said...

Hi Peter,

Thanks for your suggestion.

I trying a read data from a Text object using
textcon = @ie.TextArea("shippingOptions").SelectText(:beginIndex => 1 :endIndex => 20)

It returns me nil and following error
IO failed: wrong argument type Symbol (expected String).

I even tried by changing the object type to TypeArea in Flex application. but i got the same output.

Any suggestions from you will be helpful...

Regards,

Peter Motzfeldt said...

Hi

You are lacking a comma in between the beginindex and endindex, don't know if that went missing in the copy or you are missing it in your test?

This works for me:
@ie.text_area("tfTextArea").select_text(:begin_index => 0, :end_index => 11)

Navarasu said...

Hi Peter !
Thanks for ur reply ...
Flex spy inspect only the SWF loader and its not inspecting component of the swf file that i want to load.
Now i m automating only by compiling the application with the all swc files.

Now, i m trying to click the menubar.
For controlling the menubar only show event is available in the XML and I found unable to click the menu or the sub menu using the show command.
Can u give any idea to click the menu or sub menu in the menu bar.

mahkhaled said...

Hi Peter,
Good work Peter. I have a problem when trying to fire mouse_move event. I have tested it with many components and it doesn't fire.

Peter Motzfeldt said...

Hi Navarasu

I assume you are using version 0.0.4?

Hav eyou looked at the example tests, there should be a test for å menubar with a submenu.

Peter Motzfeldt said...

Do you use the 0.0.4 version or the 0.2 version for the mouse_move?

mahkhaled said...

I am using 0.0.4 version

Hari Kishan said...

Hi Peter,

Code::

require 'win32ole'
require 'test/unit'
require 'funfx'
class FlxTest < Test::Unit::TestCase
def setup
@ie = Funfx.instance@ie.start(true)
@ie.start(true)
@ie.speed = 1
@ie.goto("http://localurl.html","localurl")
end
end

Error:
NameError: uninitialized constant FlxTest::Funfx

Funfx variable is not recognised, I followed all the steps given. Should I initialize Funfx constant? If yes how should i initialize.

chiku said...

Hi There,

I have installed Ruby and FunFX gem.When I try to run the test case example given on the page. I get an error similar to

NoMethodError: undefined method `label' for nil:NilClass

Which few of other users have also faced and asked in your other blog.

Can you tell me or point me in right direction what am I missing or need to do or check to resolve this problem

thanks

Chronicles of a ToolSmith said...

Hey Peter, need a small help. As it turns out that FunFX cannot select a particular row in a table unless I provide each and every values of all the cells separated by '|'. I was thinking of placing some hidden values such as an id against each of the rows in the table. This id will help me click on that particular row. Is it actually possible? Happy to discuss further.

praveen said...

Hi Peter,
Can we test the application using FunFx in a test machine where the flex builder is not available. That is by accessing the application in a browser.

praneeth kumar said...

Hi peter,

This might look a silly question at this stage, but I really need an answer. I have an application readily built with flex3 (not built by me, my client has it). My task is to automate a huge set of test cases. I have tried exploring open flex automation tools available and found FunFx interesting as all other tools need some or other swf/swc to be placed with source files or in app sever while buiding the application. I assumed Funfx would not need this approach and started exploring the framework. Could you please confirm if this the same case with FunFx and it requires swc file to be placed with app source files, in which case my client wouldnt allow me to do so and Funfx may not be useful for automation to me. Quick response would really help me alot as I have already spent last 3 nights on Funfx which are effecting my job hours.

Thanks,
Panni

Peter Motzfeldt said...

Hi Panni

FunFX along with all other tools that are based on the automation framework from Adobe must be compiled with an additional swc. I should be possible to compile the already compiled swf with the new swc I think, I am not sure.

- Peter

praneeth kumar said...

Thanks very much for the immediate response peter. I will check if I can compile FunFx swc with my app swf again and let u know if I succeed.

anil.sonune said...

Hi Peter,

I am newbie to Funfx I am using Eclipse Classic SDK with Ruby & flex plugin,
i am trying to run ruby application but getting following error.


C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- fastercsv (LoadError)
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from C:/Ruby/lib/ruby/site_ruby/1.8/funfx/decoder.rb:2
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from C:/Ruby/lib/ruby/site_ruby/1.8/funfx.rb:4
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from test_case.rb:2

-Thanks,
-Anil

AbhishekSreepal said...

Hi Peter,

Does Funfx supports xpath to identify an object?

nil said...

Hi Peter
Just a simple question.Does Funfx tool supports Mac Os and safari browser?

Peter Motzfeldt said...

It does support Mac and Safari

nil said...

Hi Peter

Thanks for your quick response.When I tried to install Funfx gem in Mac OS it is showing below message:

ERROR:While executing gem...(Gem::RemoteFetcher::FetchError)
Connection refused-connect(2)(Errno::ECONNREFUSED)
getting size of http://gems.rubyforge.org/Marshal.4.8


Please help me in this regard.

Prasan said...

hi Peter,

Its really a great effort.I have a doubt do we really have to recomiple our flex code with automation agents?? Because we are third party tester and client is not ready to do this for us.a