0

How can I simulate the enter key in Selenium webdriver?
I want to choose a menu in the drop down for countries and list is chosen only upon hitting enter or clicking one of the list options.
Here is my code uptill the point of the enter key. the code breaks at the 7th line.

it('Should let valid users login' .function () {
    browser.url('/customer/signup');    browser.element('#customer_user_attributes_first_name').setValue('Name');
    browser.element('#customer_user_attributes_last_name').setValue('lastname');
    browser.element('#customer_user_attributes_email').setValue('test@email.com');
    browser.element('#customer_company').setValue('company');
    browser.element('#customer_phone_number').setValue('2222222222');
    browser.click('.select2-selection__arrow')[0]
    browser.element('.select2-search__field').setValue('United States');
  • Refer this post http://stackoverflow.com/questions/1629053/typing-enter-return-key-in-selenium – Akbar Apr 18 '16 at 05:45
  • @Akbar This is for JS. if I add .sendKeys(Keys.ENTER) then I get an error that keys is not defined. Do you know of an import for keys ? error "1) Should let valid users login: Keys is not defined" – Sushma Rao Apr 18 '16 at 06:20

1 Answers1

0
browser.actions().sendKeys(browser.Key.ENTER).perform();
Rajnish Kumar
  • 2,828
  • 5
  • 25
  • 39