How to Use Select Tag Choice Again

How to handle Driblet-down menu

What is Drop-down?

A driblet-down list (abbreviated drop-down; besides known as a drop-down menu) is a graphical control element, similar to a listing box, that allows the user to cull one value from a listing. When a drop-down list is inactive, it displays a unmarried value. When activated, it displays a list of values, from which the user may select one. When the user selects a new value, the control reverts to its inactive state, displaying the selected value. It is often used in the design of graphical user interfaces, including web design.

This tutorial illustrates how to handle the drib-down listing using Katalon Studio built-in keywords.

The below paradigm shows what the sample select command has.

  1. Index: The alphabetize of the option to exist selected/deselected.
  2. Value: Thevalue of the "value" attribute.
  3. Characterization: The exactly displayed text of a particular option

DropDown Methods Explanation

Deselect All Options

We accept a multi-select drop down every bit the following, values in a multi-select combo box include Admin, HR, Networking, Developer, Tester. This drop-downwards allows users to select multiple items.

Multiple Attribute drop-down

We already accept several items selected, for case, and at present we want all selected items to be deselected. How can we reach this using Katalon?

We have a keyword called "deselectAllOption". This will deselect all the selected items in a combo box.

Manual Mode:

DeSelectAll Manual mode

Script Manner:

                              'Launch Browser'                                WebUI                .                openBrowser                (                'C:\\\\Users\\\\User\\\\Desktop\\\\DropDown\\\\MultiSelection_dropDown.html'                )                                'Maximize the window'                                WebUI                .                maximizeWindow                ()                                'Select all the Options'                                WebUI                .                selectAllOption                (                findTestObject                (                'comboBox_Role'                ))                                'Deselect all the options'                                WebUI                .                deselectAllOption                (                findTestObject                (                'comboBox_Role'                ))                                'Taking the count of number of Selected Options and Storing it in a variable'                                NoOfSelectedOptions                =                WebUI                .                getNumberOfSelectedOption                (                findTestObject                (                'comboBox_Role'                ))                                'After Deselect verifying the Number of Selected options with Actual result to Expected'                                WebUI                .                verifyEqual                (                NoOfSelectedOptions                ,                0                )                          

Get the number of selected options ('getNumberOfTotalOption')

This keyword returns a Count of number of options which are being selected in the combo box

For example, let'due south say in the combo box below the values Admin, HR are selected. If we desire to get the number of selected options, nosotros can employ the keyword 'getNumberOfTotalOption'. In this example, information technology will render 2.

Get-Number-Of-Selected-Options-Example

Manual Way:

Get_Number_of_Selected_Option_manual

Script Mode:

                              'Launch Browser'                                WebUI                .                openBrowser                (                'C:\\\\Users\\\\User\\\\Desktop\\\\DropDown\\\\MultiSelection_dropDown.html'                )                                'Maximize the window'                                WebUI                .                maximizeWindow                ()                                'Select All values available in the dropdown by Select All choice'                                WebUI                .                selectAllOption                (                findTestObject                (                'comboBox_Role'                ))                                'Capturing the Number of selected Values and storing information technology in a variable'                                SelectedItems                =                WebUI                .                getNumberOfTotalOption                (                findTestObject                (                'comboBox_Role'                ))                                println                (                'No of Selected Roles are '                +                SelectedItems                )                                'Verifying the number of Options selected with Expected result'                                WebUI                .                verifyEqual                (                SelectedItems                ,                5                )                          

Get Number of Full Option (getNumberOfTotalOption)

This keyword returns the number of options listed in the philharmonic box.

Case:

We have a drop-downwardly and want to get the total number of available options in a driblet-down then we will use 'getNumberOfTotalOption'.

Total_Options_Image

As it has v options in the dropdown it will render a value 5.

Manual Mode:

Get Number of Total Options Manual

Script Way:

                              'Launch Browser'                                WebUI                .                openBrowser                (                'C:\\\\Users\\\\User\\\\Desktop\\\\DropDown\\\\MultiSelection_dropDown.html'                )                                'Maximize the window'                                WebUI                .                maximizeWindow                ()                                'Capturing the Toal Number of  Values in the dropdown and storing information technology in a variable'                                TotalOptions                =                WebUI                .                getNumberOfTotalOption                (                findTestObject                (                'comboBox_Role'                ))                                println                (                'No of Roles are :'                +                TotalOptions                )                                'Verifying the number of Options in the dropdown with Expected result'                                WebUI                .                verifyEqual                (                TotalOptions                ,                v                )                          

Select All Option

It will select all options from the list.

Manual Fashion:

SelectAll Manual

Script Fashion:

                              'Launch Browser'                                WebUI                .                openBrowser                (                'C:\\\\Users\\\\User\\\\Desktop\\\\DropDown\\\\MultiSelection_dropDown.html'                )                                'Maximize the window'                                WebUI                .                maximizeWindow                ()                                'Selecting all Options'                                WebUI                .                selectAllOption                (                findTestObject                (                'comboBox_Role'                ))                                'Capturing the Number of selected Values and storing it in a variable'                                SelectedOptions                =                WebUI                .                getNumberOfSelectedOption                (                findTestObject                (                'comboBox_Role'                ))                                'Verifying the number of selected options with Expected result'                                WebUI                .                verifyEqual                (                SelectedOptions                ,                5                )                          

Select Choice Past Index

It will select the option at the given index. Index always starts from 0.

Case 1:

If nosotros desire a select 'February' from the below drop downwards so we will pass input ii in the value.

Hither in this example, we are Validating verify Option Selected Past Index Also.

Select by Index Example

Transmission Mode:

SelectbyIndex manual

Script Mode:

                              'Open browser'                                WebUI                .                openBrowser                (                'file:///C:/Users/User/Desktop/Dropdown.html'                )                                'Maximize the Window'                                WebUI                .                maximizeWindow                ()                                'Select the dropdown value past Select pick By alphabetize Method'                                WebUI                .                selectOptionByIndex                (                findTestObject                (                'dropdown_Month'                ),                2                )                                'Verifying the Option is Selected by Index choice'                                WebUI                .                verifyOptionSelectedByIndex                (                findTestObject                (                'dropdown_Month'                ),                2                ,                60                )                          

Example 2:

If we want a select  Feb to Apr from the below combo box then nosotros volition laissez passer input every bit Value 2-4 and Value type as String.

Select_options_by_passing_Range_value

Input_Dialog_Box

Select Option Past Label

It will select the choice which has the exactly displayed text of a particular selection.

Example:

If nosotros desire to select 'Apr' from the drib-downwards and so nosotros need to laissez passer exactly visible text from it.

In this Case nosotros are also verifying the option is select by Label Value by using Verify selection Selected By Label.

SelectByLabel_Expample

Transmission Style:

Select_option_By_label_Manual

Script Mode:

                              'Open up browser'                                WebUI                .                openBrowser                (                'file:///C:/Users/User/Desktop/Dropdown.html'                )                                'Maximize the Window'                                WebUI                .                maximizeWindow                ()                                'Select the dropdown value past Select choice By Label Method'                                WebUI                .                selectOptionByLabel                (                findTestObject                (                'dropdown_Month'                ),                'Apr'                ,                false                )                                'Verifying the Selection is Selected past Characterization option'                                WebUI                .                verifyOptionSelectedByLabel                (                findTestObject                (                'dropdown_Month'                ),                'Apr'                ,                false                ,                60                )                                WebUI                .                closeBrowser                ()                          

Select Selection past Value

It will Select the option which has value of the "value" attribute.

Example:

If nosotros want to select 'Mar' from the drop-down and so nosotros need to laissez passer the value equally 3 as "Mar" has the value as three for Value attribute.

Hither in this example we are Validating verify Option Selected Past Value As well.

SelectByValue Example

Transmission Mode:

Script Mode :

                              'Open browser'                                WebUI                .                openBrowser                (                'file:///C:/Users/User/Desktop/Dropdown.html'                )                                'Maximize the window'                                WebUI                .                maximizeWindow                ()                                'Selecting the month from Select By value method'                                WebUI                .                selectOptionByValue                (                findTestObject                (                'dropdown_Month'                ),                '3'                ,                false                )                                'Verifying the Option is Selected by Value option'                                WebUI                .                verifyOptionSelectedByValue                (                findTestObject                (                'dropdown_Month'                ),                'iii'                ,                false                ,                60                )                                WebUI                .                closeBrowser                ()                          

Using Katalon built-in keywords nosotros tin simple handle dropdowns, we will look into other scenarios of dropdowns such as 'verifying dropdown values are in alphabetical', 'verifying expected and actual dropdown values' using custom keywords. Y'all may download the source code hither.

For further instructions and help, please refer to Katalon Studio WebUI tutorials.

Feedback

brewerupold1972.blogspot.com

Source: https://docs.katalon.com/katalon-studio/docs/how_handle_drop_down_menu.html

0 Response to "How to Use Select Tag Choice Again"

Publicar un comentario

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel