0

I have a <select> with a few <option>s that I am able to select in Selenium IDE with the select command.

<td>select</td>
<td>//div[3]/div/div/div/div[2]/select</td>
<td>value=38</td>

Great. (these are recipients for an internal email message)

But, apparently our website sends a $("select").trigger("change") when a user clicks an option from the drop-down list. So even though I can select what I need, and have it show correctly on the page, when I try to send this message, I trip an error saying "you must select a recipient". I asked our dev that builds the message form and he said once a user clicks a recipient, that click also sends a $("select").trigger("change") command.

I've tried this Selenium command:

<td>runScript</td>
<td>$("select").trigger("change")</td>
<td></td>

but it does nothing. You can see what I'm trying to do here... any ideas how to send this trigger?

David Fraser
  • 6,475
  • 1
  • 40
  • 56
Atom999
  • 432
  • 5
  • 17
  • Did you try using a click event to trigger this natively? – DMart Feb 12 '16 at 18:25
  • Alos look at the answer here: http://stackoverflow.com/questions/4689969/onchange-event-does-not-get-fired-on-selenium-type-command which suggest fireEvent. – DMart Feb 12 '16 at 18:25
  • Thanks @DMart. I couldn't get a click event to work as this is from a Select2 dropdown list. The select had aria-hidden=true on it, so I couldn't just click on it, and when I targeted the element with CSS or Xpath, it didn't fire any event triggers. What finally was the solution for me was this: `fireEvent` `//div[3]/div/div/div/div[2]/select/` `select2:select` I had to dig into the Select2 documentation to find the right event to trigger. – Atom999 Feb 15 '16 at 19:10
  • Glad it worked for you. – DMart Feb 16 '16 at 16:23

1 Answers1

0

Since I was trying to select an option from a Select2 dropdown list, here's the Selenium IDE command that worked for me:

<td>fireEvent</td>
<td>//div[3]/div/div/div/div[2]/select/</td>
<td>select2:select</td>
Atom999
  • 432
  • 5
  • 17