1

I'm new to selenium, and need some help with selecting a an item from drop down. This is after research, but didn't seem to find anything.

<div class="Select-value">
<span 
class="Select-value-label" role="option" 
aria-selected="true" id="react-select-5-- 
value-item">Female</span></div>

In the code above, the value of 'Female' can be changed by 'Male' or 'Unspecified' via drop down menu.

I can get the tag with
gender = browser.find_element_by_xpath('//*[@id="react-select-5--value"]/div[1]'), but how do I change the value?

kilamondrow
  • 31
  • 1
  • 9

1 Answers1

2

I was able to get this working. I had to get the xpath of the input, and send data to that attribute.

HTML

<span class="Select-multi-value-wrapper" id="react- 
select-5--value"><div class="Select-value"><span 
class="Select-value-label" role="option" aria- 
selected="true" id="react-select-5--value- 
item">Male</span></div>  

Python:

gender = browser.find_element_by_xpath('//[@id="react-select-5--value"]/div[2]/input')
gender.send_keys("Female")
gender.send_keys(Keys.RETURN)
kilamondrow
  • 31
  • 1
  • 9