Selecting <option> with Selenium in python

  • 1 Replies
  • 994 Views
Selecting <option> with Selenium in python
« on: March 08, 2016, 19:12:59 pm »
How can I select <option> child of a <select> using selenium in python ?

WebElement.select() is not yielding results for some reason.

What am I doing wrong ?

Re: Selecting <option> with Selenium in python
« Reply #1 on: March 09, 2016, 10:46:22 am »
You can use selenium.webdriver.support.ui.Select

Code
from selenium import webdriver
from selenium.webdriver.support.ui import Select

driver = webdriver.Firefox()

select = Select(driver.find_element_by_id(id))
print select.options
print [o.text for o in select.options]
select.select_by_visible_text()

 

Sitemap 1 2 3 4 5 6 7 8