Prepare for easier test automation: Make Select2 search field accessible by script #456

Closed
wants to merge 2 commits into
from

Projects

None yet

2 participants

@jesperronn

...tically

Example:
$(obj).select2("search") => reference to the input field, select2 shows as input element. This is very
convenient for automatic testing purposes

Jesper Rønn-Jensen Added API change to select2, so you can get to the search field progr…
…amatically

Example:
$(obj).select2("search")  => reference to the input field, select2 shows as input element. This is very
                             convenient for automatic testing purposes
fdc9c12
@jesperronn

I put this change in, because I want to make Select2 easier testable. This commit creates a "search" hook to expose this.search (already defined in codebase).

$("#element_select2_enhanced").select2("search")

@ivaynberg
Collaborator

when select2 builds its containers it copies css classes from the source element. it also copies the id by setting it to s2id_

once you have the container you can find the search. in single select you will have to get the dropdown opened first.

using select2("search") is dangerous because select2 may be in an incompatible state to have the field accessed.

@ivaynberg ivaynberg closed this Feb 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment