I am running Selenium headless on a Linux machine, and it can't find a specific element. However, I run the same exact code on a Windows machine and it finds the element without a problem. I have the latest version of the driver on my Linux machine. Any ideas how to fix this?
options = Options()
options.add_argument('--no-sandbox')
options.add_argument("--headless")
options.add_argument('user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/97.0.4692.71 Safari/537.36')
with webdriver.Chrome(options=options) as driver:
driver.get(url)
driver.find_element(By.ID, "btnhome").click()
video = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.TAG_NAME, "video"))).get_attribute("src")
The problem element is the video element. I have increased the wait time to 2 minutes as well, just for debugging. It works fine on Windows headless, but can't find it on Linux headless.
Thanks