2

I ran into the error "Cannot focus element" when using protractor and tried several solutions offered by the Protractor docs as well as from other questions on S.O. Some of these include:

1)This ignores the send.sendKeys(protractor.Key.ENTER) line:

browser.actions().mouseMove(element)
.click()
.sendKeys("admin")
.sendKeys(protractor.Key.ENTER)
.perform()

2) Gives "cannot focus element" error

browser.actions().mouseMove(element)
.click()
.sendKeys("admin")
.perform();

element.sendKeys(protractor.Key.ENTER);

3) Gives "cannot focus element" error

element.sendKeys('admin');
element.sendKeys(protractor.Key.ENTER);
John123
  • 85
  • 9
  • You don't need all of that. Just use `element.sendKeys("admin");` and then `element.sendKeys(protractor.Key.ENTER)` – FCin Mar 23 '17 at 17:14
  • That also gives 'cannot focus element' error (updated my question) – John123 Mar 23 '17 at 17:18
  • What is the element that you're trying to send keys to? – FCin Mar 23 '17 at 17:19
  • It is a popup dialogue box which may have been the problem. I couldn't get the enter key to work so as a workaround I just clicked on the popup text instead. – John123 Mar 23 '17 at 17:29
  • For popup's and different windows you should switch to that window. More here: http://stackoverflow.com/questions/28788106/switching-to-new-window-with-selenium-protractor-javascript – FCin Mar 23 '17 at 19:17

1 Answers1

0

I was not able to send the answer key, so as a workaround I just clicked on the suggestion that comes up when entering text

John123
  • 85
  • 9