Selenium can't find an element unless a screenshot is taken right before
35 views
Skip to first unread message
Avram Eisner
unread,
Jun 12, 2025, 7:28:16 PMJun 12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Selenium Users
Our team is trying to move from Create React App to Vite. Unfortunately, a lot of our existing selenium tests fail when we use the Vite dev server or production build and run them in headless mode (they all pass if Chrome is actually opened for the tests). There is a weird fix though - if we call driver.get_screenshot_as_base64() or some other screenshot method, then Selenium is able to find the element and the test passes. I've tried many other things like changing the headless browser window size and passing in a user-agent string but none of them have worked. We would like to fix the issue without resorting to a hack like the screenshot fix. Any ideas on how to fix this?
Zoltán Lehóczky
unread,
Jun 27, 2025, 12:17:38 PMJun 27
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Selenium Users
Taking a screenshot is a reported workaround for navigation issues in Chrome (that may have manifested due to Chrome's performance management becoming more aggressive). See https://groups.google.com/g/selenium-users/c/vfG6A6XVkA0 for tips.