I have a multiline text and when I am simply putting the whole text into a form using sendKeys, the form gets submitted on each line break.
I tried replacing the ne
What worked for me using python 3 was make use of ActionChain as Tamas said and @Arount posted on Python and Selenium - Avoid submit form when send_keys() with newline
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()