0

[very new to selenium]

I am using python selenium to click drop downs on a webpage. I can successfully do this using xpath. All the drop downs I want to click are exactly like that ofcourse with the number changing for each of them after the select:

gender = driver.find_element_by_xpath('//*[@id="react-select-7--value"]/div[2]/input')
gender.send_keys('Male')
gender.send_keys(Keys.DOWN)
gender.send_keys(Keys.DOWN)
gender.send_keys(Keys.RETURN)

How can I unique identify the react-select-20--value to click on the drop down ?

Below is the html from the 'highest' div class that encapsulates the react-select-20--value I want to click here, in this Gender.

Other drop downs have a similar structure too.

<div class="col-md-2">
    <div class="form-input  form-group has-error">
    <span class="glyphicon glyphicon-asterisk"></span>
    <label for="customer.gender" class="control-label">Patient Gender</label>
    <span class="input-group">
    <div class="Select is-searchable Select--single">
    <div class="Select-control">
    <span class="Select-multi-value-wrapper" id="react-select-20--value">
    <div class="Select-placeholder">Select:</div>
    <div class="Select-input" style="display: inline-block;">
    <input aria-activedescendant="react-select-20--value" aria-expanded="false" aria-haspopup="false" aria-owns="" role="combobox" value="" style="box-sizing: content-box; width: 5px;">
    <div style="position: absolute; top: 0px; left: 0px; visibility: hidden; height: 0px; overflow: scroll; white-space: pre; font-size: 14px; font-family: Helvetica, Arial, sans-serif; font-weight: 400; font-style: normal; letter-spacing: normal; text-transform: none;">
    </div>
    </div>
    </span>
    <span class="Select-arrow-zone">
    <span class="Select-arrow"></span>
    </span>
    </div>
    </div>
    </span>
    <span class="help-block">Select Gender</span>
    </div>
</div>

edit: this is not duplicate question because I can select the drop down but can not select the drop down when the link ID changes.

4
  • can you share the link of the webpage from where you are downloading data if it is a public website? Commented Oct 30, 2018 at 6:11
  • 1
    Possible duplicate of How to use python selenium to select value in React-Select Component dropdown? Commented Oct 30, 2018 at 11:51
  • @thebadguy I can not because it is a private page with HIPAA data Commented Oct 30, 2018 at 14:27
  • @Navarasu not duplicate, I can use and select the drop down but not identify it uniquely. Commented Oct 30, 2018 at 14:28

0

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.