I have 2 sorting buttons in the page, they are Recent and Name, when I open the page, we could see the Name button is clicked initially, the Recent button is not. I would write a e2e test by protractor to verify that the Recent button is not click when i just open the page.
The html elements below:
<button ng-click="setFilter('-dateorder')" class="col-xs-6 btn btn-default" ng-class="{active:isSelected('-dateorder')}" data-toggle="tooltip" data-original-title="Sort by Recent" tabindex="0">Recent</button>
<button ng-click="setFilter('name')" class="col-xs-6 btn btn-default active" ng-class="{active:isSelected('name')}" data-toggle="tooltip" data-original-title="Sort by Name" tabindex="0">Name</button>
What I was done is below, but seems incorrect, becuase the nameclick1.isEnabled() is always return ture, even though I change to Name button
it('Verify the sort button click or not', function() {
var nameclick1=element(by.buttonText('Recent'));
expect(nameclick1.isEnabled()).toBe(true);
//expect(nameclick1.getAttribute('enabled')).toBe(false);
});
Can anyone helps here?
expect(element(by.css('button:not(.active)[data-original-title*=Recent]')).isPresent()).toBe(true);
A "Recent" element without "active" class is present.