Eliminate entering QR - Whatsapp web automated by selenium - Java
Use profiles!
from selenium import webdriveroptions = webdriver.ChromeOptions()options.add_argument(r"user-data-dir=D:\Python\Memory\WebWhatsAppBot")navegador = webdriver.Chrome(executable_path="D:\Python\WebWhatsAppBot\chromedriver.exe", chrome_options=options)navegador.get("https://web.whatsapp.com/")
Marcelo's answer is correct but poorly explained in my opinion, so here's what worked for me:
Create a folder in your project directory to store all the cache that the chromedriver session will create (it's also nice to ignore the content in your .gitignore
file).
And then, start the webdriver options and set the directory.
from selenium import webdriverfrom selenium.common.exceptions import NoSuchElementExceptionfrom selenium.webdriver.common.keys import Keysimport timeoptions = webdriver.ChromeOptions()options.add_argument(r"user-data-dir=./driver/data")driver = webdriver.Chrome(executable_path=r'./driver/chromedrive84_win', options=options)driver.get('https://web.whatsapp.com/')
You can skip the qr code scaning after first attemp if you have not use
ChromeOptions options = new ChromeOptions();options.addArguments("--incognito"); options.addArguments("--no-sandbox");
after removing --incognito type option