How can I select an option from a dropdown using Ruby Selenium Webdriver

0 votes
How can I select an option from a dropdown using Ruby Selenium Webdriver?
Aug 26, 2019 in Selenium by Swasti
4,768 views

1 answer to this question.

0 votes

Hey Swasti, you can try following lines of code to perform selection of an option from a dropdown:

driver = Selenium::WebDriver.for :firefox
driver.navigate.to "http://facebook.com"

options = select_list.find_elements(:tag_name => "option")
options.each do |opt|
  if opt.text == "March"
    opt.click
    break
  end
end
answered Aug 26, 2019 by Anvi
• 14,150 points
This works fine.
drop = driver.find_element(:id, "month")
choose = Selenium::WebDriver::Support::Select.new(drop)
choose.select_by(:text, "Feb")

Hi @Pranish Katwal, thank you for your contribution to the Edureka Community.

Register/Sign up on the community to gain points for further contributions. You may ask questions, answer, upvote, and downvote an answer. Each of these would fetch you points and you could be among the top contributors and win exciting merchandise from Edureka.

Cheers!

Related Questions In Selenium

0 votes
1 answer

How can I select date from a datepicker div using Selenium Webdriver?

Hey Jeevika, you can use following automation ...READ MORE

answered Jul 15, 2019 in Selenium by Abha
• 28,140 points
12,182 views
+1 vote
1 answer

Can I select multiple options from a dropdown using Python Selenium webdriver?

Hi Dhwani, you can use following code ...READ MORE

answered Jul 31, 2019 in Selenium by Abha
• 28,140 points
4,927 views
0 votes
1 answer

Select an item from a dropdown list using Selenium WebDriver

Use this then it will work - new ...READ MORE

answered Apr 9, 2018 in Selenium by Vardy
• 2,360 points
7,773 views
0 votes
1 answer

How can I locate web elements from a web page using Selenium Webdriver?

Hey @Dushyant, Locating elements in WebDriver is ...READ MORE

answered May 29, 2019 in Selenium by Shreya
2,906 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,686 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,149 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,228 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,880 views
0 votes
3 answers

What are the different ways to select an option from a dropdown using Selenium Webdriver?

So follow this steps for solution: First click ...READ MORE

answered Dec 16, 2020 in Selenium by Roshni
• 10,480 points
52,150 views
0 votes
1 answer

How can I perform multiple selection of options in a dropdown using Select class in Selenium?

Hey Priyansh, you can select multiple options ...READ MORE

answered Jul 8, 2019 in Selenium by Anvi
• 14,150 points
3,227 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP