Selenium with headless chrome fails to get url when switching tabs Selenium with headless chrome fails to get url when switching tabs selenium selenium

Selenium with headless chrome fails to get url when switching tabs


I believe you are just using argument as "--headless" for better performance you should select screen size too. Sometimes, due to inappropriate screen size it cannot detect functions which you are looking for. try using this code or just add one line for size.

from selenium import webdriverchrome_options = Options()chrome_options.add_argument("--headless")chrome_options.add_argument("--window-size=1920x1080")driver = webdriver.Chrome(chrome_options=chrome_options)

Don't forget to put other arguments according to your need in "driver".