1

I have tried the SELECT class utility with all it's functions including selectByVisibleText() and others but no success. Following is the div hierarchy of my elements and then is the <select> box which I want to read.

<div class="abc">
  <div class="def">
    <div class="xyz">
       <div></div>
       <select class="qwe" id="asd">
         <option class="zxc" label="test" value="01">01</option>
and options are so on till value 12.

How do I get to select the options using selenium webdriver in python ??

EDIT 1: The code I tried is as follows:

select = Select(browser.find_element_by_id("asd"))
select.select_by_visible_text('04')

And,

 eMonth = browser.find_element_by_id("asd")
 eMonth.send_keys("10")
1
  • you tried it, what was the result? any error messages? pls include it in your question Commented Jan 20, 2016 at 15:03

2 Answers 2

1

You can use Select class with explicit wait

wait = WebDriverWait(driver, 10)
dropDown = wait.until(expected_conditions.visibility_of_element_located((By.ID, 'asd')))
select = Select(dropDown)
select.select_by_value('01')

By the way, selectByVisibleText() is Java syntax.

Sign up to request clarification or add additional context in comments.

Comments

1

Mostly select class will work as drop down has select tag. good to have some info like code used and exception faced. i hope you tried with giving wait if fails, sleep.

we can also select drop down values by using sendkeys. below is the command is java

 driver.findElement(By.id("asd")).sendKeys("01");

Thank You, Murali

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.