Selenium webdriver on Safari: Keys.ENTER not worki

2019-09-13 13:13发布

问题:

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.

回答1:

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.