I've found a solution (example at this link How to line break in WhatsApp with Selenium when sending a message?
But I've a problem sending Multiline Message with WhatsApp using Python and Selenium.
This is My code :
message = excel_data['Message'][msg]
# Locate search box through x_path
search_box = '//*[@id="side"]/div[1]/div/label/div/div[2]'
person_title = wait.until(lambda driver:driver.find_element_by_xpath(search_box))
# Clear search box if any contact number is written in it
person_title.clear()
# Send contact number in search box
person_title.send_keys(str(excel_data['Contact'][count]))
count = count + 1
msg=msg+1
# Wait for 2 seconds to search contact number
time.sleep(2)
try:
# Load error message in case unavailability of contact number
element = driver.find_element_by_xpath('//*[@id="pane-side"]/div[1]/div/span')
except NoSuchElementException:
# Format the message from excel sheet
message = message.replace('{customer_name}', column)
person_title.send_keys(Keys.ENTER)
actions = ActionChains(driver)
actions.send_keys(message)
actions.send_keys(Keys.ENTER)
actions.perform()
I've a file excel with 2 column : 1° Column Phone Number and 2° Column the message
All work well if message is a single message. If message is on multi line doesn't work.
Ex.:
Message =
Hello
Gundam How are you?
I'm well
WhataApp send 3 message :
First with Hello
Second with Gundam How are you?
Third with I'well
I need all in One message in multiline
Could you help me modifying my code ?
I tried adding this but doesn't work:
ActionChains(driver).send_keys(message).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()
Thanks a lot for your help