Could you help me in my question, please?
I use Excel VBA & selenium to send WhatsApp messages to multiple contacts. I need to send images using copy & paste, but when I use (driver.SendKeys keys.Control, "v") ,A message appears"1 image you tried adding has no content".
Note1: Image is a link to an excel table.
Note2:I don`t like using the VBA command,(application.sendkeys "^v",true) because :
-It requires me to leave the pc until the code finishes, and it may take long time because messages are a lot.
-It can mistake because it requires WhatsApp window to be active.
public driver as new webdriver
Sub Whatsapp_new()
Dim keys As New Selenium.keys
Dim FindBy As New Selenium.By
'==============================================================
'start chrome
driver.SetProfile Environ("LOCALAPPDATA") & "\Google/Chrome\User Data"
driver.AddArgument "profile-directory=Default"
driver.Start "chrome"
driver.Window.Maximize
driver.Wait (1000)
driver.Get "https://web.whatsapp.com"
'==============================================================
'wait whatsapp to load
Do Until driver.IsElementPresent(FindBy.XPath("//div[@title='Search input textbox']"))
DoEvents
Loop
'==============================================================
'copy picture from sheet
for i = 1 to 100
range("a1")= i
ActiveSheet.Shapes("Picture 1").Select
Selection.Copy
phone_number =range("b2").value
'send message and picture
driver.Get "https://web.whatsapp.com/send?phone=" & phone_number & "?I=pt_br&text=how are you today"
driver.Wait 1000
driver.FindElementByXPath("//div[@title='Type a message']", 3000).SendKeys keys.Enter
driver.Wait 1000
driver.SendKeys keys.Control, "v"
driver.Wait 1000
driver.SendKeys keys.Enter
driver.Wait 1000
next
End Sub
Please help me
Thanks in advance