简体   繁体   中英

Unable to select item from dropdown in Protractor

I haven't figured out a way to select an item from the dropdown that I'm trying to interact with. The only thing I've been able to do is show at least one of the names of the possible dropdown items by using: element.all(by.model('payAcc.paymentType.selected')).getText().then(function(name) { console.log(name); });

This prints out ['Bank Account']. I've tried several methods such as by.model , by.id , etc.

Here is the html that deals with the dropdown: HTML代码

Here is another picture of the same thing that shows the dropdown, and elements from the web browser console, which may be more helpful.: 在此处输入图片说明

My whole goal is to be able to select either of the dropdowns to continue on with filling in the rest of the appropriate information for the account. The version of Protractor we're using is v2.5.1. Any help from Protractor gods is appreciated.

I think you can just send keys to the dropdown :

var dropdown = element(by.model('payAcc.paymentType.selected'));
dropdown.sendKeys("Debit/Credit Cards");

If that doesn't work, I had to click on the drop down first, before being able to click on elements within the drop-down to select. So it would be something like:

dropdown.click().then( function() {
       dropdown.get(index of option you want to select).click()
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM