这是弹出窗口的截图我正试图自动化WhatsApp,但当我尝试访问 WhatsApp api 它给出了一个警告,打开另一个链接。我试着用selenium关闭它,但它没有检测到警报,也没有错误或任何东西。
def sendmesssage():
phone = "899928555"
url = "https://api.whatsapp.com/send?phone=+911234567890&text=Hi%20There"
browser.get(url)
while True:
try:
WebDriverWait(browser, 5).until(EC.alert_is_present()).dismiss()
print("found")
alert = browser.switch_to.alert
print(alert.text)
browser.find_element_by_xpath('//*[@id="action-button"]').click()
return;
except :
pass
我错误的做法是,你是你必须使用数字与国家代码。包括国家代码,再试一次,例如印度是+91,所以把电话号码改为+91899928555,应该可以正常工作。一个广告弹出窗口或一个对话框。