Traversing Spark Dropdown list with large number of items Flex SDK 4.x using QTP

ISSUE

Traversing Spark Dropdown list with large number of items Flex SDK 4.x using QTP

SOLUTION

The solution consists of two parts

PART 1

Change the Dropdown code [Application code] to include a property

useVirtualLayout=”false”

[for more details please refer : Using virtualization with list-based controls]


<s:DropDownList id=”DropDownTest” dataProvider=”{arrElementsDdl}” useVirtualLayout=”false” selectedIndex=”0″/>

as in the sample application provided Please refer code below : SparkDropDownFidelity182460106CODE

PART 2

Consists of using the automation Scripts as described below,

‘Get the number of  children under the Drop Down

Browser(“Browser”).SparkApplication(“SparkDropDownFidelity182460106″).SparkDropDownList(“DropDownTest”).Open
Num=Browser(“Browser”).SparkApplication(“SparkDropDownFidelity182460106″).SparkDropDownList(“DropDownTest”).GetItemsCount
Print “‘GetItemsCount’ value for Spark Drop Down: “&Num

‘Loop through the items inside Drop Down using SelectIndex
For i=0 to Num-1
Browser(“Browser”).SparkApplication(“SparkDropDownFidelity182460106″).SparkDropDownList(“DropDownTest”).SelectIndex i

‘Always open the list before checking for the items
Browser(“Browser”).SparkApplication(“SparkDropDownFidelity182460106″).SparkDropDownList(“DropDownTest”).Open
temp=Browser(“Browser”).SparkApplication(“SparkDropDownFidelity182460106″).SparkDropDownList(“DropDownTest”).SparkListLabel(“automationindex:=index:”&i).Exist
print “Object Exists ? : ” &temp
set SparkGetItem=Browser(“Browser”).SparkApplication(“SparkDropDownFidelity182460106″).SparkDropDownList(“DropDownTest”).SparkListLabel(“automationindex:=index:”&i)

‘Access the properties of the item
ItemAutomationname=SparkGetItem.GetROProperty(“automationname”)
ItemAutomationindex=SparkGetItem.GetROProperty(“automationindex”)
print “Spark Automationname : ” & ItemAutomationname&” Automationindex : ” &ItemAutomationindex
Next

ADDITIONAL INFORMATION

SparkDropDownFidelity182460106CODE

<?xml version=”1.0″ encoding=”utf-8″?>
<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/mx” minWidth=”955″ minHeight=”600″>

<fx:Declarations>
<!– Place non-visual elements (e.g., services, value objects) here –>

</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;

[Bindable]
public var arrElementsDdl:ArrayCollection = new ArrayCollection([
{label:”Item 1″, data:1},
{label:”Item 2″, data:2},
{label:”Item 3″, data:3},
{label:”Item 4″, data:4},
{label:”Item 5″, data:5},
{label:”Item 6″, data:6},
{label:”Item 7″, data:7},
{label:”Item 8″, data:8},
{label:”Item 9″, data:9},
{label:”Item 10″, data:10},
{label:”Item 11″, data:11},
{label:”Item 12″, data:12},
{label:”Item 13″, data:13},
{label:”Item 14″, data:14},
{label:”Item 15″, data:15}]);
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout/>
</s:layout>

<s:ComboBox id=”cboxTest” dataProvider=”{arrElementsDdl}” selectedIndex=”0″ />
<s:DropDownList id=”DropDownTest” dataProvider=”{arrElementsDdl}” useVirtualLayout=”false” selectedIndex=”0″/>
<mx:Text id=”testText” text=”SDK 4.0 test 2 with useVirtualLayout=false”/>
</s:Application>

Comments are closed.