4

The environment I'm using is

  • Protractor 5.3.1
  • Cucumber 4.2.1
  • IE11
  • selenium-webdriver 3.6.0

On the page in the application I am testing there is no button to click on, you need to enter text into an input field then send the ENTER key. The following works fine in chrome and firefox.

browser.driver.findElement(By.className('myClass')).then((text) => {
    text.sendKeys('abc'); // this works fine in IE11
    text.sendKeys(Key.ENTER);
});

The issue is that it won't send the ENTER key in IE11, it just skips over this step and fails on the next step in the test.

I also tried this:

browser.actions().sendKeys(protractor.Key.RETURN).perform();

When I tried this the following error is returned:

[15:29:10] E/launcher - UnsupportedOperationError: sendKeysToActiveElement
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:13:22.693Z'
System info: host: 'ABC', ip: '9.162.xxx.xxx', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_181'
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
AutoTester
  • 41
  • 1
  • 3

1 Answers1

1

As you mentioned that the following line doesn't works:

text.sendKeys(Key.ENTER);

As an alternative you can use:

text.sendKeys(Key.RETURN);

You can find a detailed discussion in Typing Enter/Return key in Selenium

Incase the element is within a form you can also use another alternative as:

text.submit();

You can find a detailed discussion in Selenium: submit() works fine, but click() does not

Additionally, while you work with Internet Explorer v11 you need to configure your test framework with the Required Configuration. Apart from these specifically only for IE 11 you will need to set a registry entry on the target computer so that the driver can maintain a connection to the instance of Internet Explorer it creates as follows:

  • For 32-bit Windows installations, the key you must examine in the registry editor is:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. 
    
  • For 64-bit Windows installations, the key is:

    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. 
    

You can find a detailed discussion in Internet Explorer 11 getting stuck randomly while executing tests through IEDriverServer and Selenium

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    I tried 'text.sendKeys(Key.RETURN)' but it didn't work. I read the discussion 'Typing Enter/Returnkey in Selenium' and tried some of the suggestions in it but still can't get it work. My element is not within a form so that doesn't work either. I think its related to IE11, as like I said it works fine in chrome and firefox – AutoTester Aug 24 '18 at 10:26
  • @AutoTester Checkout my updated answer and let me know the result. – undetected Selenium Aug 24 '18 at 10:37
  • I already had added that property into my registry so that's not the issue – AutoTester Aug 24 '18 at 12:11
  • Did you take some time to cross check the related discussion I have provided for your reference and the links within that discussion? – undetected Selenium Aug 24 '18 at 12:51
  • Yes, I read the other discussions you mentioned and changed some capabilities settings as suggested but none made a difference – AutoTester Aug 24 '18 at 14:35