Micro Focus QTP (UFT) Forums
selecting values from the dropdown 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: selecting values from the dropdown webelement (/Thread-selecting-values-from-the-dropdown-webelement)



selecting values from the dropdown webelement - poojaarora014 - 04-17-2014

Hi All,

I am automating the RTC 4.0.5 workitem creation using QTP.
Issue is now all the weblist is converted to the webelement.
I need a way to select a value from the dropdown of the webelement.

I tried with the small command to change the innertext of the attribute using :-

Code:
Set objWebElement    =    Browser("name:="&BrowserProperty).Page("title:="&BrowserProperty).WebElement("class:=ValueHolder ViewBorder","Index:=6")
        objWebElement.Object.innertext    =    attribute vale

But after saving the attribute value is not retained, then I tried using:-

Code:
Browser("name:="&BrowserProperty).Page("title:="&BrowserProperty).WebElement("innertext:=unassigned","Index:=21").click
    set wshShell = CreateObject("WScript.Shell")
    wait 5
    wshShell.SendKeys "{DOWN}"
    wshShell.SendKeys "{DOWN}"
    wshShell.SendKeys "{ENTER}"
    wshShell.SendKeys "{TAB}"

For first selection it is working, but if I want to change the selected value then it is not working.

I tried with the WebTable too but none helped.

Please suggest me solution ASAP.

Thanks,
Pooja


RE: selecting values from the dropdown webelement - basanth27 - 04-21-2014

How would you be able to select the right value if you use the sendkeys? For eg: If there are 10 values, and you want to select 5th value, you may want to do 5 times down but during runtime if the value has been changed then you wont get the desired value.

BTW, you mentioned about webtable? where is the webtable located?

Try this, Record the action and see the script generated? Does it generate a script?


RE: selecting values from the dropdown webelement - poojaarora014 - 04-21-2014

Thanks Basanth for replying, actually there is a WebTable object, inside which we have attribute at column1 and their respective values at column2.

Just FYI, at column2 we have a WebElement dropdown.

I figured out lots of different ways for object identification (as mentioned in the initial comments of the thread), but could not find the way for selection.

Even I agree with you about the SendKeys "{DOWN}" is not a good way for the huge list.

Please suggest me some solution.

Thanks,
Pooja


RE: selecting values from the dropdown webelement - basanth27 - 04-22-2014

Did the recording (low-level) work? did it generate any script?