I wrote a code to send a WhatsApp message using selenium and WhatsApp web, and it works great but I can't figure pot why it won't work in headless mode, it doesn't lunch the browser at all.
when I run it in headless mode and without the crome path option it succeeds to launch the browser but of course, it doesn't work because I have to have the data. this is the error message: "selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist".
I also tried to add options like '--no-sandbox' and '--disable-dev-shm-usage' but it still doesn't work.
BASE_URL = "https://web.whatsapp.com/"
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument(config.CHROME_PROFILE_PATH)
def main():
driver = Chrome(executable_path='driver/chromedriver.exe',
options=options)
driver.get(BASE_URL)
driver.maximize_window()
driver.implicitly_wait(config.WAIT_TIME)