【发布时间】:2021-01-27 18:05:13
【问题描述】:
我目前正在开展一个项目,我正在通过 url 自动化 whatsapp 消息。像这样https://wa.me/number_here
每当我正常执行此操作时,一切正常,但是当我尝试自动执行此操作时,会出现一个 whatsapp 弹出框并阻止所有内容,我的意思是所有内容,没有右键单击没有开发人员选项,这就是为什么我无法获得 x 路径该弹出窗口上的按钮。我试过(driver.shift_to,alert.close),但它说没有这样的警报。我试图通过 contains(text) 方法找到按钮,但也没有用。这是我的代码。
chrome_options = Options()
chrome_options.add_argument('--user-data-dir = user-data')
chrome_options.add_experimental_option('excludeSwitches', ['enable-automation'])
chrome_options.add_argument('--disable-notifications')
chrome_options.add_argument('--disable-popup-blocking')
chrome_options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=chrome_options, executable_path= driver_path)
wait = WebDriverWait(driver, 60)
contact = f'https://wa.me/{number}'
driver.get(contact)
time.sleep(3)
alert = wait.until(EC.alert_is_present())
alert.accept()
请帮助我如何绕过此弹出窗口。谢谢
【问题讨论】:
标签: python selenium google-chrome