How to check if an item is enabled

I need to check with Protractor if the button in my angular application is on, so this is my test:

it('submit should not be enabled',function() { var price = by.name('price'), oldCategory = by.name('oldCategory'), newCategory = by.name('newCategory'), oldPayment = by.name('oldPayment'), newPayment = by.name('newPayment'), item = by.name('item'), submit = by.id('submitButton'); expect(submit.isEnabled().toBe(false)); }); 

when i run the test get this error:

  TypeError: Object By.name("price") has no method 'isEnabled' 
+8
angularjs protractor
source share
2 answers

The brackets are copied to expectation :

 expect(submit.isEnabled().toBe(false)); 

it should be:

 expect(submit.isEnabled()).toBe(false); 

And you are using protractor locator incorrectly:

 submit = by.id('submitButton'); 

it should be:

 submit = element(by.id('submitButton')); 

You can find many examples in the protractor specifier .

+14
source share

Try the following:

 submit = element(by.id('submitButton')); 
+1
source share

All Articles