I have a partial select2 element using Angular UI http://angular-ui.imtqy.com/
The problem I encountered is that the element is required, and although I successfully set the field through the following code, the required attribute is not deleted, since the Angular model should not be updated due to an external change, and I'm not sure how either provide $ scope.apply (), or use another Angular function to continue the test.
First allow the launch of direct jQuery functions: (taken from How to execute jQuery from Angular e2e test area? )
angular.scenario.dsl('jQueryFunction', function() { return function(selector, functionName /*, args */) { var args = Array.prototype.slice.call(arguments, 2); return this.addFutureAction(functionName, function($window, $document, done) { var $ = $window.$;
Then, to change the value of the field:
jQueryFunction('#s2id_autogen1', 'select2', 'open'); jQueryFunction('#s2id_autogen1', 'select2', "val", "US"); jQueryFunction('#s2id_autogen1', 'select2', 'data', {id: "US", text: "United States"}); jQueryFunction('.select2-results li:eq(3)', 'click'); jQueryFunction('#s2id_autogen1', 'trigger', 'change'); jQueryFunction('#s2id_autogen1', 'select2', 'close'); input('request._countrySelection').enter('US');
Note that not all of these functions are needed to reflect the changes in ui, just everything I used to try to get this to work ...