splinter icon indicating copy to clipboard operation
splinter copied to clipboard

Add support for TAB or ENTER keys in browser.type

Open mpibpc-mroose opened this issue 8 years ago • 4 comments

Dear splinter team, I'm using django-froala-editor in my projects and want to run behavior tests. As it is a bit tricky to get the FroalaField inputs as this are contenteditable DIVs. I'm using the following approach with navigating with TAB keys:

import splinter
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains

with splinter.browser as b:
    b.visit("/")
    # click on an visible element
    self.browser.find_by_id("id_foo").first.click()
    # next element is a FroalaFieldInput and is defined by tab order
    actions = ActionChains(b.driver)
    actions.send_keys(Keys.TAB)
    actions.send_keys("AB")
    actions.perform()

I would like to somehow have a more "natural" possibility to type "TAB" or other special keystrokes, e.g. by passing selenium Keys to browser.type(). I think as this is implemented in Selenium it could be useful in splinter, too.

mpibpc-mroose avatar Nov 30 '17 13:11 mpibpc-mroose

Hi @mpibpc-mroose I believe that it is a nice feature to have. Thanks.

andrewsmedina avatar Nov 30 '17 14:11 andrewsmedina

yes i'm very confused about this function,really need it

caoliang12121 avatar Dec 27 '17 09:12 caoliang12121

Yep, needed as well from my side. It's crucial in fact..

Formartha avatar Feb 02 '18 10:02 Formartha

I'm interested in helping build this.

I'd rather not have to import anything new if I already have a Browser instance. Would this API work?

browser.type_tab()
browser.type_enter()

Or about about this?

browser.type(tab=True)
browser.type(enter=True)

jacebrowning avatar Mar 08 '18 20:03 jacebrowning