Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor - clicking and sendKeys not working

I am writing a Protractor test, and as part of the test I wish to clear the content of a particular field (on a textarea), and then use the sendKeys method to write some content onto that textarea.

Here's the code from my test:

var commentField = element(by.css('input[ng-model="comment"]'));
console.log(commentField);
commentField.clear();
commentField.sendKeys('Here is a comment'); 

The console log confirms that I am indeed finding a control, but as soon as it hits the clear() method the test just hangs.

Any ideas what might be happening here?

like image 656
Martin Milan Avatar asked Mar 13 '23 10:03

Martin Milan


2 Answers

We use browser.ignoreSynchronization = true; if the page is not angular page. Because the protractor is coded for angular. But, I see ng selector:

var commentField = element(by.css('input[ng-model="comment"]'));

This error may be due to other things:

  1. Browser driver (Try to use chromedriver)
  2. Lack of testability plugin. Please visit this link for more information: https://www.npmjs.com/package/protractor-testability-plugin

Make sure you use jasmine2 framework, and to update webdriver, type to command line this: webdriver-manager update

like image 159
ktom Avatar answered Mar 23 '23 04:03

ktom


Just to let people know - I needed to use

browser.ignoreSynchronization = true;

after the call to move to the target page, but before attempting to click, clear or edit anything.

Happy days!

like image 23
Martin Milan Avatar answered Mar 23 '23 04:03

Martin Milan