Micro Focus QTP (UFT) Forums
how to select from a dropdown list showing as an webelement? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Regular Expressions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Regular-Expressions)
+--- Thread: how to select from a dropdown list showing as an webelement? (/Thread-how-to-select-from-a-dropdown-list-showing-as-an-webelement)



how to select from a dropdown list showing as an webelement? - smukherjee - 04-20-2016

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.


RE: how to select from a dropdown list showing as an webelement? - smukherjee - 04-22-2016

Can anyone solve this problem?


RE: how to select from a dropdown list showing as an webelement? - vinod123 - 04-29-2016

what is the browser and browser version. What is the version of QTP you are using


RE: how to select from a dropdown list showing as an webelement? - supputuri - 05-04-2016

(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


RE: how to select from a dropdown list showing as an webelement? - vinod123 - 05-07-2016

try using xpath identification as mentioned above