I am using Python 3 with selenium.
Let's assume var = "whatever\nelse"
My problem is that when I use elem.send_keys(var)
it sends the form after "whatever" (because of the newline)
How may I replace "whatever\nelse" with whatever + SHIFT+ENTER + else?
Or is there any other way to input newlines without actually using javascript or substituting newlines with the newline keystroke?
Note: elem is a contenteditable div.
This is the method I actively use. At least this is simpler.
Did you tried something like:
Like
ActionChains
will chainkey_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.