WhatsApp Web automation with Selenium not working WhatsApp Web automation with Selenium not working selenium selenium

WhatsApp Web automation with Selenium not working


I realise this post is older, but it still seems to be frequently looked at.The keystroke explanation of @vhad01 makes sense but did not work for me.

A simple dirty workaround that worked for me:Replace input() with

import timetime.sleep(25)

while 25 is the amount of seconds it will be waited until the code will be further executed. (15 should also be sufficient to scan the QR code,...).


The way I implement the scanning of the QR code is by detecting if the search bar is present or not on the page.

from selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECchatlist_search = ".jN-F5.copyable-text.selectable-text"web.get("https://web.whatsapp.com")WebDriverWait(web, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, chatlist_search)))

This would wait until the chat search-bar is rendered on the page, or it will timeout in 60 seconds.


This line :

input()

is waiting for a keystroke to continue.Simply press any key after scanning.