Python and Selenium - Avoid submit form when send_keys() with newline

Did you tried something like:

ActionChains(driver).key_down(Keys.SHIFT).key_down(Keys.ENTER).key_up(Keys.SHIFT).key_up(Keys.ENTER).perform()

Like

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

driver = webdriver.Chrome()
driver.get('http://foo.bar')

inputtext = 'foo\nbar'
elem = driver.find_element_by_tag_name('div')
for part in inputtext.split('\n'):
    elem.send_keys(part)
    ActionChains(driver).key_down(Keys.SHIFT).key_down(Keys.ENTER).key_up(Keys.SHIFT).key_up(Keys.ENTER).perform()

ActionChains will chain key_down of SHIFT + ENTER + key_up after being pressed.

Like this you perform your SHIFT + ENTER, then release buttons so you didn't write all in capslock (because of SHIFT)

PS: this example add too many new lines (because of the simple loop on inputtext.split('\n'), but you got the idea.