You have maybe found a better solution than this yourself, but I would like to show you a simple (maybe not the best) way to find specific item in a combobox. As you maybe know or have experienced Flex does only draw what you see and hence an item you do not see in the combobox is not possible to select. Due to this you will have to scroll the elements to make it visible.
I played around a couple of minutes and just created this while loop that scrolls all the items, and picks out the item with the itemrenderer "12"
@ie.combo_box("cbTest").open
num_rows = @ie.combo_box("cbTest").num_rows
position = 0
while(position <= num_rows)
@ie.combo_box("cbTest").scroll(:position => position)
begin
@ie.combo_box("cbTest").select(:item_renderer => "12")
position = num_rows + 1
rescue
position += 1
end
end
Support for this might be built into the FunFX framework, that it searches like that automatically, or what do you think?
13 comments:
Thanks for the post.
I don't know why but I'm getting this error when I try to open the combobox:
NoMethodError: private method `open' called for #Array:0x3542f88
Do you know why?
Another thing... is it possible to use watir and FunFX together??
Something like:
@ie=Watir::IE.new()
@ie.goto("http://myapplication.com/play.do")
@ieFlex=Funfx.instance(@ie,"BFP")
Thanks.
Hi Mariovsky, sorry about the late response.
The array error is because there exists multiple display objects with the name you have provided. You can either narrow the search by going into the Flex tree for instance:
@ie.box("somebox").combo_box("name).open
or you can do like this if you know which you want:
@ie.combo_box("name)[0].open
I think I have talk to you on email on the point about watir and FunFX and you provided me with a solution :-)
I will tomorrow release a new version of FunFX that supports the use of multiple windows and combining watir with FunFX. This version is made true by you and Bill Torla at Endeca
Thank you very much.
I'm going to use this library for the framework I'm working on my company.
Thanks a lot for your work, please if you need some help... I'm here.
I'll let you know any progress I get.
Ciao!
Hi,
I've been wondering, what exactly "12" is in the lines like this:
@ie.combo_box("cbTest").select(:item_renderer => "12")
Is it an id of the itemRenderer? What if I use custom itemRenderer in the combobox, so item names don't work as :item_renderer?
There's also yet anotehr question unrelated to comboboxes, but I'm not sure where else to put it... I have a datagrid with numeric values with commas, like "95,134". Now, if I use tabular_data on the datagrid, it returns a comma-delimited string, and so it is impossible to tell column delimiters from decimal commas. Is there any workaround?
Hi
The item_renderer = "12" is just an example. In the application I used this in the combo_box had the values 1 to 31 (days in a month, just to have a long list of simple items) The item_renderer searches for the text shown in the combo_box or automation name of an item shown in the combo box.
With the tabular data with commas, I have been pulling my hair out my self about this. Have not had the time to make it better. I recommend using some ruby parsing of the string. I will put this on the to do list :-)
Yeah, I understand that in that particular combobox "12" was one of the items. The question is, what it is in terms of Flex. The reason for asking, I have a combobox with custom item renderer (basically, icon + text label), and pure item name does not work for item selection. Automation names seem to be null for all items, as well as ids. I'm just not good enough at Flex to be able to recommend my developers what exactly should be changed in the Flex code for Funfx to be able to pick the items.
Hi
To be able to pick up custom item renderers within such a component as the combobox, you must specify a uniqe automationname on the custom_itemrenderer (some of the data describing the element the item renderer is showing).
For instance if you have a custom itemrenderer that is a vbox with to labels you can do like this:
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" automationName="{data.@name}">
<mx:Label text="{data.@name}"
fontSize="11"
fontWeight="bold" />
<mx:Label text="{data.@abbrev}"
fontSize="9"
paddingLeft="10" />
</mx:VBox>
Hi Peter:
Thanks for the excellent work. I have been using FunFx for a while and really like it.
I am having an issue right now try to drag-drop an item from one list to another, I can select/drag-drop the visible items, but not able to do with invisible items, so I tried to use the approach described here, however everytime when I try
@ie.list("dataFieldList").scroll( :position => -5)
or
@ie.list("dataFieldList").mouse_scroll( :delta => -1)
I got the following error:
NoMethodError: private method 'gsub' called for -5:Fixnum
any ideas on what causes the error? Any help is greatly appreciated!
Just did a google search and found the answer myself from this link:
http://groups.google.com/group/
ruby-talk-google/msg/
29820f7a7e444265
thanks!
Hi peter,
i am making a web application in which i have to select a accordion and than in accordion i have to select a tree.
Through funfx i am able to select accordion but i am not able to open/select a tree folder..
i m using..
@ie.accordion("accordionMyDocs").change(:related_object => "webshar1") @ie.tree("dataTree").open(:item_renderer => "FirstAlbum")
I am getting this error:
NoMethodError: private method `open' called for #Array:0xaa026e8
I have also used :
@ie.tree("dataTree")[1].open
But i am getting this error:
RuntimeError: 'dataTree' not Visible.
Thanks. It worked :-)
Post a Comment