当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - 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?

网友答案:

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

网友答案:

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!

分享给朋友:
您可能感兴趣的文章:
随机阅读: