Micro Focus QTP (UFT) Forums

Full Version: how to select from a dropdown list showing as an webelement?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to select the particular country dynamically from the drop down list appearing as a web element.
There is no major difference in the property except x-path and coordinates for the different country showing in the dropdown list.

Below the property for a particular dropdown county:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
"Class Name:=WebElement",
"abs_x:=414",
"abs_y:=564",
"class:=",
"height:=12",
"html id:=",
"html tag:=DIV",
"innerhtml:=",
"innertext:=",
"outerhtml:=<div style=""left: 0px; top: 0px; width: 181px; height: 12px; border-right-color: rgb\(220, 220, 220\); border-left-color: rgb\(220, 220, 220\); border-right-width: 1px; border-left-width: 0px; border-right-style: solid; border-left-style: solid; position: absolute; z-index: 1;"" unselectable=""on""></div>",
"outertext:=",
"role:=",
"title:=",
"type:=",
"visible:=True",
"width:=181",
"x:=414",
"xpath:=//DIV\[@id=""DS""\]/DIV\[1\]/DIV\[1\]/DIV\[1\]/DIV\[4\]/DIV\[1\]",
"y:=510"
++++++++++++++++++++++++++++++++++++++++

I have tried the below code snippet that is working dynamically sometime but each time x-path changed for a particular country showing in the dropdown list and then the code snippet is not working, selecting the different country.

 Set obj = Description.Create()
 obj("micclass").Value = "WebElement"
 obj("html tag").Value = "DIV"
    For i = 0 to strCount-1 
        strPpty = objWE(i).GetROProperty("xpath")
        If strPpty = "//DIV[@id=""DS""]/DIV[1]/DIV[1]/DIV[1]/DIV[35]/DIV[1]" Then
            Browser("QlikView").Page("EMD Plus Analytics_Dev.qvw").WebElement("xpath:="& strPpty &"").Click
            Exit For
        End If
    Next

Please suggest how I can select a particular country from the drop down list.

attaching the screenshot of the application.
Can anyone solve this problem?
what is the browser and browser version. What is the version of QTP you are using
(04-29-2016, 11:06 AM)vinod123 Wrote: [ -> ]what is the browser and browser version. What is the version of QTP you are using

Replace "United States Of America" with the country which you wan to select from the list of countries.
Code:
xpathValue = "//div[@id='DS']/descendant::div[text()='United States Of America']"

Browser("QlikView").Page("EMD Plus Analytics_Dev.qvw").WebElement("xpath:="& xpathValue &"").Click
If still you are facing issue, then please share the screenshot the object spy by selecting the country
try using xpath identification as mentioned above