def hacker_typing(browser, spinter_selection, code):
"""We need to break Splinter abstraction and fall back to raw Selenium here.
Note: There is a bug of entering parenthesis due to IPython capturing keyboard input.
http://stackoverflow.com/questions/22168651/how-to-enter-left-parentheses-into-a-text-box
"""
elem = spinter_selection[0]._element
driver = browser.driver
# Activate IPython input mode
ActionChains(driver).click(elem).send_keys(Keys.ENTER).perform()
# Type in the code
a = ActionChains(driver)
a.send_keys(code)
a.perform()
time.sleep(1.0)
# Execute the text we just typed
a = ActionChains(driver)
a.key_down(Keys.SHIFT).send_keys(Keys.ENTER).key_up(Keys.SHIFT)
a.perform()
评论列表
文章目录