1

I've tried for days to figure this one out. I have a selector that I can't figure out. It seems to be a regular select statement with multiple options but when clicking one option directly it changes the title on a button. I can't figure out how to manipulate it. All I want to do is find a specific selection option and select it. I don't need to select multiple options.

The code I'm seeing is as follows:

<select multiple="" id="assignTo" data-placeholder="Select Instructor(s)" title="Instructor(S)" name="instructors" class="form-control bootstrapmultiselect" style="display: none;">
<option value="864979">Joe Smith</option>
<option value="355944">Mary Jones</option>
<option value="44177">Bill Smith</option>
<option value="551573">Susan Carter</option>
<option value="883308">Brian Bird</option>
</select>

<div class="btn-group" style="width: 100%;">
   <button type="button" class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" title="None selected" style="width: 100%;">None selected <strong class="caret"></strong></button>

Here's the code I've tried:

    drop = select(driver.find_element_by_id('assignTo'))
    instructor_option = WebDriverWait(driver,5).until(lambda x: x.find_element_by_xpath("//select[@id='assignTo']/option[text()='Bill Smith']"))
    instructor_option.select()

Any ideas? I appreciate any help at all!

  • can you share you screen of dropdown with DOM? – Upkar Singh May 6 at 10:38
  • Try click on the dropdown first before you select any element. Also better if you can use a xpath.contains() method to select the text. – Joe Oct 4 at 4:19
0

There is nothing wrong with your select locator. I assume the thing that changes are underlying values of available options, try selecting by visible text:

drop.selectByVisibleText("some_name");

I have used java syntax, here is python:

drop.select_by_visible_text("some_name")
  • Thanks Moro. Unfortunately that didn't work. I think the issue has something to do with the fact that the selected item ends up as a title attribute for the button – Brian H May 5 at 20:38
  • So, how exactly does it fail? Can you add some logs to the question? – Moro May 5 at 20:51
0

would you at all be able to share any screenshots of what you are trying to automate, it would help massively in coming up with the most viable solution.

At the moment I would recommend possibly trying to use SendKeys to the element to move the selection down until it matches what you are looking for.

Otherwise please do add some screenshots and I'll try my best to help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.