hadesfv
hadesfv

Reputation: 386

selenium reading redirection on whatsapp

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

Hello, I am trying to write a function to "wait" until the user actually scans QR code, i.e return True if he is logged in and False if he is not. I checked how it's done in the network tab, basically it is a POST to WhatsApp then User is logged in.

if there is another way to do this, I am all ears.

Upvotes: 1

Views: 150

Answers (1)

Moshe Slavin
Moshe Slavin

Reputation: 5204

Use WebDriverWait() with 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')))

Upvotes: 2

Related Questions