question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with WebDriverJS sendKeys

See original GitHub issue

I’m currently working on the TodoMVC Angular 2 implementation, you can see the work in progress via this pull request: https://github.com/tastejs/todomvc/pull/1558

The TodoMVC project uses WebDriverJS in order to automate the testing of each implementation. Unfortunately Angular 2.0 is failing due to some very strange issue. Here’s a very simple automated test that illustrates the issue:

var webdriver = require('selenium-webdriver');

var driver = new webdriver.Builder().
   withCapabilities(webdriver.Capabilities.chrome()).
   build();

driver.get('http://colineberhardt.github.io/angular2-todo/');
driver.sleep(1000); // sleep to give the app time to bootstrap
var input = driver.findElement(webdriver.By.className('new-todo'));
input.sendKeys('buy some eggs', webdriver.Key.ENTER);
input.sendKeys('do the shopping', webdriver.Key.ENTER);
input.sendKeys('test all things', webdriver.Key.ENTER);
driver.sleep(10000); // sleep so that we can see the results
driver.quit();

(The above test is executed against a simplified version of the TodoMVC app, which can be found here).

Unfortunately the text input become completely mangled after the first addition of ‘buy some eggs’:

capture

I have tried all sorts of changes to the TodoMVC app itself, however, the only way I can make the tests work is to add a pause in-between each keystroke:

var webdriver = require('selenium-webdriver');

var driver = new webdriver.Builder().
   withCapabilities(webdriver.Capabilities.chrome()).
   build();

driver.get('http://todomvc.com/examples/angular2/');
driver.sleep(1000); // sleep so that we can eliminate startup issues
var input = driver.findElement(webdriver.By.className('new-todo'));

function sendSlowly(text) {
  for (var i = 0, len = text.length; i < len; i++) {
    input.sendKeys(text[i]);
    driver.sleep(1);
  }
  input.sendKeys(webdriver.Key.ENTER);
  driver.sleep(1);
}

sendSlowly('buy some eggs');
sendSlowly('do the shopping');
sendSlowly('test all things');
driver.sleep(10000); // sleep so that we can see the results
driver.quit();

This gives the expected result, with three items added to the todo list.

Does anyone have any ideas? I’d love to get the TodoMVC Angular2 app updated!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
juliemrcommented, Jun 22, 2016

I am now unable to reproduce this with RC2/RC3. I think the issues has been fixed. Please open a new bug if you can show us a reproducible test case. Thanks!

0reactions
angular-automatic-lock-bot[bot]commented, Sep 8, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to sendkeys using webdriverjs specifically F11 to ...
i used to use C# and selenium and that worked fine using this method on chrome and different browsers. It finds the element...
Read more >
sendKeys() not working in Selenium Webdriver - Tutorialspoint
If we encounter issues while working with the sendKeys method, then we can use the JavaScript Executor to input text within an edit...
Read more >
Solution for sendkeys(CharSequence) in Selenium
How to change the compiler version · 1- Right click on project. SendKeys is not working in Selenium · 2- Click on Java...
Read more >
sendKeys not working in Selenium Webdriver - Edureka
I was trying to send keys to a text box and send a tab key both at the same time to check for...
Read more >
Solution for Alert sendKeys() not working in Chrome Browser ...
In this session, I have provided the solution for one of the problem that Automation Engineers face while automating the scenario: i.e. ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found