2

I am using angular-multi-select dropdown from https://github.com/isteven/angular-multi-select. Now i want to write test cases in protractor.

<div ng-show="!attribute.isMultivalued && page != 'view'" 
     class="select-group" 
     multi-select 
     input-model="typesDataDup"
     output-model="attribute.types"
     button-label="typeName"         
     item-label="typeName" 
     tick-property="ticked" 
     selection-mode="single"
     helper-elements="filter"
     is-disabled = "page == 'view'">
</div>

I am unable to send data using model because here we don't mention ng-model.

Could anyone help me out in writing test case for it?

2 Answers 2

5

You can rely on other attributes and use by.css to find the element. For example:

element(by.css('div.select-group'))

or

element(by.css('div[multi-select]'))

As far as I see from the angular-multi-select source code, select options are represented with button elements. Use element.all() to find all buttons inside and click the desired one, for instance, Select All:

element.all(by.css('div[multi-select] button')).then(function(options) {
    options.forEach(function(option) {
        option.getText().then(function(text) {
            if (text.indexOf("Select All") != -1) {
                option.click();
            } 
        });
    });
});
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks @alecexe. Yes but it can't select particular option using this code
@AnushaNilapu that's ok, it was an interesting challenge. I'll leave it here in case it would help somebody in the future. Thanks for sharing your solution!
yeah it may help others
1

To solve this i took css help. I had checked css in inspect element then i got this solution

element.all(by.buttonText('None selected')).then(function(items) {
   items[1].click();
}); 
element.all(by.model('inputLabel.labelFilter')).then(function(items) {
   items[1].sendKeys(protractor.Key.DOWN+protractor.Key.DOWN);
});
ptor.sleep(200);
element.all(by.css('.multiSelectFocus')).then(function(items) {
   items[0].click();
});

Here i am selecting particular option using DOWN key

Comments

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.