I'm feeling a bit confused about Protractor at the moment.
It seems like sometimes my elements load in time for the next action to happen, while other times they do not. I'm assuming this has something to do with its asynchronous nature.
For example, sometimes this code passes and sometimes it doesn't:
it('should create an audience using an existing audience and should be able to filter and search for that audience', function () {
page.audienceTab.click();
$('.panel-list .row .panel-list-header .btn').click();
$('.panel-list div .btn').click();
$('.edit-audience .row .col-md-3 accordion .panel-group .name-filter .panel-collapse .panel-body section input').sendKeys('test-audience');
$('.expose-offset button').click();
$('.col-xs-4 input').sendKeys('test-audience');
expect($('.panel-list .panel h3').getText()).toEqual('test-audience');
});
Is there any way to ensure that elements are loaded before the next action is triggered?