from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox(executable_path='/home/geckodriver')
driver.get('https://web.whatsapp.com/')
#function to check weather qr code is scanned or not
您好,我正在尝试编写一个“等待”功能,直到用户实际扫描QR码为止,即如果他已登录则返回True,否则返回False。我在“网络”标签中检查了此操作的完成情况,基本上这是对WhatsApp的POST,然后用户已登录。
如果还有另一种方法可以做到,那么我非常的高兴。
答案 0 :(得分:2)
将WebDriverWait()
与expected_conditions.invisibility_of_element_located()
一起使用:
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
WebDriverWait(driver, 60).until(EC.invisibility_of_element_located((By.CLASS_NAME, 'landing-window')))