Friday, March 11, 2016

promises, promises

At work I've been learning Protractor by the time-honored method of "pick stuff up on the fly from existing code" without taking the time to sit and read much.

A coworker used the same technique, so together I was able to correct their code... if you're reading from an input element, maybe one selected like this:
this.dealNameField = element(by.model('deal.name'));

You probably want
this.dealNameField.getAttribute('value');

and NOT
this.dealNameField.getText();

(I was surprised there wasn't a convenience function ala .getValue() , akin to what's there in jQuery land)

More significantly, I was harshly reminded that Protractor deals with promises, and if you try to do a lot of poking around with the requisite expect() type code, you're in for a world of confusion.

Also, note to future self,
 expect(widget.alertMessage.isPresent()).toBe(false); 
is a pretty useful construct (where widget.alertMessage was the element css selector thingy)

No comments:

Post a Comment