Tuesday, 18 March 2014

Get the selected value in combobox in selenium webdriver in python.

We can get the data from combobox using get_attribute method as illustrated in the below example.

from selenium import webdriver

from selenium.webdriver.support.ui import Select


driver = webdriver.Firefox()

driver.maximize_window()

driver.get("http://register.rediff.com/register/register.php")

try:

   
 e = driver.find_element_by_name("DOB_Day")

 select = Select(e)

 select.select_by_index(3)

 selOption = select.first_selected_option
   
 print(selOption.get_attribute("value"))
   
 driver.close()

except Exception as e:

    print ("Exception occured", format(e));

finally:

    driver.quit()

    print ("finally")




What do you think on above selenium topic. Please provide your inputs and comments. You can write to me at reply2sagar@gmail.com

No comments:

Post a Comment

Buy Best Selenium Books

Contributors