My goal is to write:
Hello
World!
on facebook messenger but I can only achieve:
Hello
World!
This is my code:
driver.get('https://www.facebook.com/messages/t/[RECIPIENT]')
time.sleep(1)
MessageBox = driver.find_element_by_class_name('_5rpu')
Message = 'Hello\nWorld!'
NewLine = ActionChains(driver)
Lines = Message.split('\n')
for x in range(0,len(Lines)):
print(x)
print(Lines[x])
MessageBox.send_keys(Lines[x])
NewLine.key_down(Keys.SHIFT).key_down(Keys.ENTER).key_up(Keys.ENTER).key_up(Keys.SHIFT)
if x != len(Lines)-1:
NewLine.perform()
print('NEW LINE')
The output is:
0
Hello
NEW LINE
1
World!
Seeing as NEW LINE is printed only once, it seems the ActionChain is only called once yet creates two lines.