4

I have automated the whatsapp web with the selenium.

It is able to send messages to the list of phone numbers... No matter even if the phone number is saved in phone contacts or not

How Can i avoid re-loading of the same URL again and again for every phone number...?

Java Code :

WebDriverWait wait = new WebDriverWait(driver, 60);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("side")));

System.out.println("Scanned the Barcode and loaded the web WhatsApp....");


// SendToList is a list of phone numbers...


for (int i = 0; i < SendToList.size(); i++)
{
     String Number = SendToList.get(i);
     System.out.println("Opening link....");
     driver.get("https://web.whatsapp.com/send?phone="+Number);

     try
     {
          Alert alert = driver.switchTo().alert();
          alert.accept();
          System.out.println("Leave Page Alert accepted....");
     }
     catch(NoAlertPresentException e)
     {
          System.out.println("Leave Page Alert not detected....");
     }

     System.out.println("Typing the message text here....");

}

Is there any way instead of re-loading the URL https://web.whatsapp.com/send?phone="+Number again & again, for sending message to every new phone number...? Like injecting javascript or anything else?

Andrei Suvorkov
  • 5,559
  • 5
  • 22
  • 48
sandhya sasane
  • 1,334
  • 12
  • 19

0 Answers0