0

I did lots of things to solve this problem... but any answer can't solve my problem.

I want to select drop down option.

This is my homepage's html code

<div class="selectric-wrapper">
<div class="selectric-hide-select">
<select id="ymd_birth1" data-reactid=".2mlafrhlvk.2.0.2.1.1.1.0.0" tabindex="0"><option data-reactid=".2mlafrhlvk.2.0.2.1.1.1.0.0.$0">2015</option>
<option data-reactid=".2mlafrhlvk.2.0.2.1.1.1.0.0.$1">2014</option>
<option data-reactid=".2mlafrhlvk.2.0.2.1.1.1.0.0.$2">2013</option>
<option data-reactid=".2mlafrhlvk.2.0.2.1.1.1.0.0.$3">2012</option>
<option data-reactid=".2mlafrhlvk.2.0.2.1.1.1.0.0.$4">2011</option>

and this is my python code.

driver.find_element_by_xpath("//select[@id='ymd_birth1']/option[text()='1994']").click()

When I printed all options by

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

The result was terrible...

like..

[<selenium.webdriver.remote.webelement.WebElement (session="cdadecb9-0706-4383-a6bf-e1a2211e56ba", element="{7a3e2067-6a3c-4e21-816b-93d8c38288be}")>, <selenium.webdriver.remote.webelement.WebElement (session="cdadecb9-0706-4383-a6bf-e1a2211e56ba", element="{53bf8d75-a380-4a45-a1e8-7315505589bf}")>]

[u'', u'', u'', u'', u'', u'', u'', u'', u'', u'....]

please help me!! I can't solve this problem for 5 hours....

1 Answer 1

1

You can't click on drop down option when the combo box is closed. Use Select class with explicit wait instead

wait = WebDriverWait(driver,10)
dropDown = wait.until(expected_conditions.visibility_of_element_located((By.ID, 'ymd_birth1')))
select = Select(dropDown)
select.select_by_visible_text('1994')
Sign up to request clarification or add additional context in comments.

3 Comments

It doesn't work, too. with ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with
Another error is coming.. dropDown = wait.until(expected_conditions.visibility_of_element_located(By.ID, 'ymd_birth1')) TypeError: __init__() takes exactly 2 arguments (3 given)
@ChangHakYeon Add another set of brackets around By.ID, 'ymd_birth1' : dropDown = wait.until(expected_conditions.visibility_of_element_located((By.ID, 'ymd_birth1')))

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.