![]() |
|
How to select the drop down option by searching for partial text - 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 Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners) +--- Thread: How to select the drop down option by searching for partial text (/Thread-How-to-select-the-drop-down-option-by-searching-for-partial-text) |
How to select the drop down option by searching for partial text - Neetha - 07-30-2015 Hi all, I am new to QTP and trying to learn. I would like to know how to select a specific option that matches a partial text from a drop down using QTP. The drop down in my application consists of more than 100 options and I need qtp to select some options based on the string values stored in a spreadsheet. I have a list of string values and need to compare this strings with the options in the drop down and select the one that matches with the string. These string values are only partial texts from the drop down values. Ex. If the drop down options are 2015 Jan 2015 Feb 2015 Mar 2014 Jan 2014 Feb 2014 Mar and I want to select any month from 2015 or 2014. So I want to search by partial text 1. 2015 2. 2014. Any help, ideas are great appreciated. Thanks in advance. RE: How to select the drop down option by searching for partial text - sporandla - 07-31-2015 Please try the below code. Here the oObjectRef is the string reference of the object (dropdown object), sVerifyListItem is the partial string that you want to check Code: Dim sStringExist, i, j, iMin, iMax, sActItemListRE: How to select the drop down option by searching for partial text - Neetha - 08-03-2015 Thanks for the reply. I tried this but would not work. I'm getting an error message when I create ObjectRef. Does qtp support this feature Code: ObjectRef = Browser(...).Page(...).WebList(...)RE: How to select the drop down option by searching for partial text - kbhargava505 - 08-04-2015 If GetItemCount and GetItem is not working for the weblist, I've other idea. First check whether are you are able to get the text of the selected item by obj.getroproperty("text") and you are able to select the item of the weblist by Up and Down arrow keys, if yes then follow this Code: ptrn=DataTable.value("Column",dtlocalsheet)Note: Not sure it works but it worked for me in winobjects RE: How to select the drop down option by searching for partial text - Neetha - 08-04-2015 Thanks for the reply. I found an alternative way to solve this. Here is what I did. 1. I pulled all the list items from the drop down and stored into a String variable of array type using Split method. 2. I compared each of these list items with the text string I have using Instr method by adding a loop. 3. If found I then checked the position if it is greater than or equal to 1. And if true then select the list item with the count that matches in the loop statement. |