The transporter cannot select the drop-down list option.

Hi, I am doing a protractor test and I have problems with my tests. My ionic application has a dropdown model name, and I tried to access it using the model name, and it works, but the problem is that it cannot select the exact option that I need to select from this drop-down list. Does he choose only the first? I wrote protractor syntax like this.

element(by.model('generalPowerOfAttorney.grantorGeneralPowerOfAttorneyForm.region')).$('[value="59"]').click(); 

But this code does not select the value 59, but the value 0, which is the default option. Is there anyone who could help me?

0
ui-automation protractor
Oct 29 '15 at 10:53 on
source share
1 answer

You should add an html source to facilitate the answer.

You can use the filter method to get the right click on an element.

 var elements = element.all(by.model('generalPowerOfAttorney.grantorGeneralPowerOfAttorneyForm.region')); elements.filter(function(elem, index) { return elem.getText().then(function(text) { return text === 'value="59"'; }); }).then(function(filteredElem){ if(filteredElem[0] !== undefined){ filteredElem[0].click(); } else { throw 'element not found' } }); 
0
Oct 29 '15 at 18:37
source share



All Articles