Four Commonly Used Methods on ComboBox in QTP/UFT

0
296
Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Four Commonly Used Methods on ComboBox in QTP/UFT
Four Commonly Used Methods on ComboBox in QTP/UFT

Four Commonly Used Methods on ComboBox in QTP/UFT

In an application today Combo box or select box or drop down is an essential part. Here developers provide choices that should be selected by user. Advantages of combobox or select box or dropdown is that it is single linear in view and restricts users to provide multi form of same data.
Very popular example could be country or state drop down. Say in a registration form ,User from India needs to select Country as India.But if this would have been a textbox, user might put Country -India  or INDIA or india. This will go to server as String.From technological point of view these are three different Strings!!!.
So by providing India on dropdown developers restrict user to select a single,defined String called India.

Commonly user methods on Combobox or Dropdown or select in QTP are-

  • Count of Items in Combobox or Dropdown or select
  • Fetch specific item from Combobox or Dropdown or select
  • Complete List of items from combobox or Dropdown or select
  • Select one from Combobox or Dropdown or select

Let us do one by one-

How to get Count of Items from Combobox or Dropdown or select

For getting count of Items from a Combobox or Dropdown or Select we will use getItemCount method.
Syntax-Variable_Name= <Hierarchy of Object >.Combobox(“Combobox_name”).GetItemsCount

dim x
x=Window("abc").WinComboBox("xyz").GetItemCount
//abc and xyz can be fetched from Object spy
//for descriptive programming
dim x
x=Window("Title:=abc").WinComboBox("name:=xyz").GetItemCount
How to get specific item from Combobox or Dropdown or select

For this case , the command we will be using is GetItem(Position).position starts from 0. It is nothing but Index value.
Syntax-Variable_Name=<Hierarchy of Object >.Combobox(“Combobox_name”).GetItem(2)

dim x
x=Window("abc").WinComboBox("xyz").GetItem(2)
//abc and xyz can be fetched from Object spy
//for descriptive programming
dim x
x=Window("Title:=abc").WinComboBox("name:=xyz").GetItem(2)
How to get complete list of Items from Combobox or Dropdown or select

For this we will be using GetContent method
Syntax-Variable_Name=<Hierarchy of Object >Combobox(“Combobox_name”).GetContent

dim x
x=Window("abc").WinComboBox("xyz").GetIContent
//abc and xyz can be fetched from Object spy
//for descriptive programming
dim x
x=Window("Title:=abc").WinComboBox("name:=xyz").GetIContent
How to select specific item from Combobox or Dropdown or select

Select is the command to set a value in the combo box
Syntax-
Variable_Name=<Hierarchy of Object >.Combobox(“Combobox_name”).Select(Value_To_Select)
or
Syntax-
Variable_Name=<Hierarchy of Object>.Combobox(“Combobox_name”).Select(Index_Value)

dim x
x=Window("abc").WinComboBox("xyz").Select("pqr")
//abc and xyz can be fetched from Object spy
//for descriptive programming
dim x
x=Window("Title:=abc").WinComboBox("name:=xyz").Select(2)
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

LEAVE A REPLY

Please enter your comment!
Please enter your name here