Selenium和WhatsApp用于将消息发送到特定的电话号码

时间:2018-07-07 07:49:36

标签: java selenium whatsapp

我已将whatsapp webselenium自动化了。

它能够将消息发送到电话号码列表... 即使电话号码是否保存在电话通讯录中

如何避免为每个电话号码一次又一次地重新加载相同的URL ??

Java代码:

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....");

}

有什么方法可以一次又一次地重新发送URL https://web.whatsapp.com/send?phone="+Number来向每个新电话号码发送消息吗?喜欢注入javascript或其他任何内容?

0 个答案:

没有答案
相关问题