1

I'm forced to use the Enter key to submit a form in automated testing (the submit button can't be targeted by an automated click event). client.Keys.ENTER works golden in all browsers... except Safari. In Safari it absolutely refuses to press Enter. Return doesn't work either. Is there some Safari Webdriver specific issue that is causing this?

UPDATE: Found the click event. It was counter intuitive and the person who made the page gave me the wrong info. Either way, still can't hit Enter, which is a problem.

Jaime Wissner
  • 81
  • 1
  • 13
  • 1
    Have set anything in your capability settings? Such as SafariOptions or native events and such... – David Baak Mar 14 '16 at 18:29
  • No. How does one go about setting up native events? I wasn't aware that was an option and I can't find any documentation on it. – Jaime Wissner Mar 14 '16 at 18:56
  • Use [desired capabilites](https://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/remote/DesiredCapabilities.html). Though I know you work in JavaScript, here's a Java example `DesiredCapabilities capability = DesiredCapabilities.safari(); capability.setCapability("nativeEvents", false); WebDriver = new SafariDriver(capability);` – David Baak Mar 14 '16 at 20:38
  • A few questions: what Selenium version? What Safari version? Did you get any errors at all? Also, are you really sure you exhausted all possibilities of clicking/invoking submit in the normal way? If the ENTER approach is troublesome, couldn't we help with your original problem? – Andrew Regan Mar 14 '16 at 23:17
  • I'm using Selenium 2.52, Safari 9.0.2, and I get no errors in the terminal when running local, but I get [this error](https://gist.github.com/Ceyaje/743bc299babb9c6d7ad6) when I run in SauceLabs. And yes. I've exhausted all options. We've literally invoked click on every possible element that should submit the form (and some that shouldn't). For reference, the site is nj.com (or any other local affiliate around the country.) The form is the top rail search bar (click the search icon). The submit button actually changes locations as you type. It's horribly written. Enter is the only way. – Jaime Wissner Mar 15 '16 at 15:28
  • I tried using `"nativeEvents": false`, but unfortunately, that made no difference. – Jaime Wissner Mar 15 '16 at 15:29
  • Also, regardless of the original problem, there is no reason I shouldn't be able to hit the enter key in Safari. I know we'll need to do it again, whether if it's checking if a form is wired correctly, or going to a different line. – Jaime Wissner Mar 15 '16 at 15:30
  • Just found the click event. – Jaime Wissner Mar 15 '16 at 15:49
  • I had a similar issues with IE and Keys. Pain in the ass. Anyway, did you try `sendKeys("\n")`; in of the form fields. Should result in hitting the Return Key. – David Baak Mar 15 '16 at 18:03
  • Woo! That did indeed work! I would have never thought to do that! Can you make that an answer so I can accept it? – Jaime Wissner Mar 15 '16 at 19:33
  • I added it as answer :) – David Baak Mar 18 '16 at 18:43

1 Answers1

2

The work around is using sendKeys("\n") in a form field in the form that you want to submit. This is equal to hitting the Return key. Another option may be to use submit() in a form field but I am sure the first suggestion works.

David Baak
  • 944
  • 1
  • 14
  • 22