This is a simple test written for Protractor, a slightly modified example from Protractor docs:

it('should find an element by text input model', function() {

  var login = element(by.model('username'));
  login.sendKeys('Jane Doe');
  var name = element(by.binding('username'));
  expect(name.getText()).toEqual('Jane Doe');

  // Point A

Explain if the code is synchronous or asynchronous and how it works.


The code is asynchronous, although it is written in a synchronous manner. What happens under the hood is that all those functions return promises on the control flow. There is even direct access, using “protractor.promise.controlFlow()”, and the two methods of the returned object, “.execute()” and “.await()”.

Other webdriver libraries, such as wd, require the direct use of callbacks or promise chains.


© 2017