简体   繁体   中英

make protractor wait for the select element to get populated with options on selecting a option in another Select element

I got two Select elements, select1 and select2. Selecting a option in select1 will populate with options in select2. I'm able to select the option in select1, but want to make protractor wait for the options to get populates in select2 and then select a option in select2 element.

i tried to use

    selectOrganizationElement.all(by.tagName('option')).filter(function(element){
        return element.getText().then(function(text){
            return text === value1;
        });
    }).click().then(function(){
        selectSchoolElement.all(by.tagName('option')).filter(function(element){
            return element.getText().then(function(text){
                return text === value2;
            });
        }).click();
    });

but its not able to select.

any Suggestions?

Try adding a browser.wait call. This would wait until there's at least one option in the selectSchoolElement :

browser.wait(function() {
  return selectSchoolElement.all(by.tagName('option')).count().then(function(count) {
    return count > 0;
  });
}, 5000);

If you want, you can make it smarter and specifically wait for the option you want to select.

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