Python Selenium如何确认JavaScript消息以打开WhatsApp Web

我正在制作WhatsApp自动化脚本来发送消息。当我运行脚本时,它要求javascript确认以打开WhatsApp网站。

我该怎么做?

我的代码:

from selenium import webdriver
import pandas as pd
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time
import os
import mysql.connector



driver = webdriver.Chrome('/Users/evilslab/Downloads/chromedriver 3')

driver.get('https://api.whatsapp.com/send?phone=0097155000XXXX)

# Click the link to activate the alert
driver.find_element(By.LINK_TEXT, "https://api.whatsapp.com wants to open this application.").click()



# Store the alert in a variable for reuse
alert = driver.switch_to.alert

# Store the alert text in a variable
text = alert.text

# Press the Cancel button
alert.dismiss()

这没有证实

评论