Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to select dropdown on value option in ruby watir?

Tags:

ruby

watir

This is my drop down and i want to select it on its value option

<select id ="">
<option value="01" title="  01 - Live animals">  01 - Live animals</option>
</select>

I know that how to select drop down on its content i.e.

ie.select_list(:id, "DropDownList_Product").select("01 - Live animals")

actually I want to select drop down on its value 01,what should i have to do for that ?

like image 529
unknownbits Avatar asked Jun 18 '13 07:06

unknownbits


People also ask

How do you select an element in Watir?

Elements are located by creating a Selector Hash, which Watir translates into the potentially complicated information the driver needs to know to identify the element. The special cases will be highlighted below, but Watir Locators: Accept String values for exact matching. Accept RegExp values for partial matching.

How do I select the value of a Dropdownlist?

The value of the selected element can be found by using the value property on the selected element that defines the list. This property returns a string representing the value attribute of the <option> element in the list. If no option is selected then nothing will be returned.

What is Watir used for?

Definition: Watir, pronounced as water, is a group of Ruby libraries for automated web browsers. It allows writing the tests which are easy to read and maintain. In other words, it is a simple and flexible tool.

What is Watir Webdriver gem?

Watir (Web Application Testing in Ruby), pronounced as "Water" is an open source tool developed using Ruby which helps in automating web application no matter which language the application is written. The browsers supported are Internet Explorer, Firefox, Chrome, Safari, and Edge.


1 Answers

Something like this should work:

ie.select_list(:id, "DropDownList_Product").select_value("01")

More information at http://rdoc.info/gems/watir-webdriver/Watir/Select#select_value-instance_method

like image 116
Željko Filipin Avatar answered Oct 27 '22 00:10

Željko Filipin