How to click "return" using Splinter
Alright, that seemed interesting. The thought popped out of nowhere but here it is:
"Return" key click is equivalent to '\n' character. Which means that every search term must be ended with a new line character. By doing this, the return key is automatically clicked and I'm taken to search results in reddit!
So, the command would look like:
b = Browser()b.visit('http://reddit.com')b.fill('q', 'intp\n')
And you're taken to search results as selenium/splinter fills the search term.
I found out that '\r' can substitute '\n', because the following code also works:
b = Browser() b.visit('http://reddit.com')b.fill('q', 'intp\r')
It works with the type function as well:
b = Browser() b.visit('http://reddit.com')b.type('q', 'intp\r')
It appears to be implemented by Selenium itself because the following code which directly calls Selenium commands also behaves the same:
b = Browser() b.visit('http://reddit.com')element = b.driver.find_element_by_css_selector('[name={}]'.format('q'))element.send_keys('intp\r')
This post mentions it as well.