Categories
Articles Flex

QTP 11 – Flex 4 – Dropdown with scrollbar

Few days back, one of our automation tester came across a weird problem in Flex 4 application. We could able to set the selected item for the dropdowns which are not having scrollbars, but the ones having scrollbars were not able to set the appropriate item.

While initally I thought it could be a problem with the custom components that we have built, I thought of testing the QTP against following approaches
1. MX dropdown
2. Sprk dropdown
3. Combo box

To my surprise, QTP couldnt able to set the appropriate item for all of these controls. While this was bit disheartning, there was no other way but to find a solution as it was like a showstopper for the application. After spending quite a few hours, I could able to figure out following code (There could be performance problems with the code, as it has been long time I have coded in VBScript)

Function findItem (selectName, c)

For i =0 To c.Count-1
it = c(i).GetROProperty("automationname")
If it = selectName Then
Browser("Browser").SparkApplication("MyApp").SparkNavigatorContent("index:3").FlexBox("index:29").SparkPanel("MyPanel").SparkSkinnableContainer("ComboBoxEntityType").SparkDropDownList("index:2").Select selectName
findItem=True
Exit function
End If
next
findItem = false
End Function

Function iterateAll(selectName, iterateIndex)
Set c=Browser("Browser").SparkApplication("MyAppp").SparkNavigatorContent("index:3").FlexBox("index:29").SparkPanel("MyPanel").SparkSkinnableContainer("ComboBoxEntityType").SparkDropDownList("index:2").ChildObjects
v = findItem(selectName,c)
If v=false Then
iterateIndex = iterateIndex+1
Browser("Browser").SparkApplication("MyApp").SparkNavigatorContent("index:3").FlexBox("index:29").SparkPanel("MyPanel").SparkSkinnableContainer("ComboBoxEntityType").SparkDropDownList("index:2").SparkScrollBar("verticalScrollBar").Change iterateIndex * 21
iterateAll selectName, iterateIndex
End If
End Function

selectName = "Others"
Set cmb=Browser("Browser").SparkApplication("MyApp").SparkNavigatorContent("index:3").FlexBox("index:29").SparkPanel("MyPanel").SparkSkinnableContainer("ComboBoxEntityType").SparkDropDownList("index:2")
cmb.Open
tc = cmb.GetItemsCount
Set c=cmb.ChildObjects
iterateAll selectName,0

By Carbon Rider

Hi this is Yogesh, welcome to my world. Being passionate about learning new technologies and building frameworks, I end up spending most of my time in front of computer. But over last few months, I realised apart from being good coder and designer (Yes I am) I have something hidden in me. And thats called ART.

One reply on “QTP 11 – Flex 4 – Dropdown with scrollbar”

Leave a Reply