Answer the question
In order to leave comments, you need to log in
How to move a line from Selenium to WhatsApp when sending a message?
Send message function:
template = {
'other':
'Текст.'
'Еще текст.'
'И еще текст.'
'Все, последний текст.'
}
def send_message(driver, answer):
driver.find_element_by_xpath('XPATH').click()
action = ActionChains(driver)
action.send_keys(answer)
action.send_keys(Keys.RETURN)
action.perform()
Text.More text.And more text.That's it, the last text.
Answer the question
In order to leave comments, you need to log in
Sim3x
helped in the solution
def send_message(driver, answer):
driver.find_element_by_xpath('XPATH').click()
for line in answer.split('\n'):
ActionChains(driver).send_keys(line).perform()
ActionChains(driver).key_down(Keys.SHIFT).key_down(Keys.ENTER).key_up(Keys.SHIFT).key_up(Keys.ENTER).perform()
ActionChains(driver).send_keys(Keys.RETURN).perform()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question