Selenium can't find an element unless a screenshot is taken

30 views
Skip to first unread message

Avram Eisner

unread,
Jun 12, 2025, 7:28:11 PMJun 12
to Selenium Users
Our team is trying to switch from Webpack/Babble to Vite. In our Vite branch, many of our selenium tests are failing if it is run in headless mode. A weird fix is that if driver.get_screenshot_as_base64() is called before looking for the element it finds the element and passes. We would like to come up with a less hacky solution to this problem.

Corey Goldberg

unread,
Jun 12, 2025, 7:44:52 PMJun 12
to seleniu...@googlegroups.com
Most likely you aren't properly waiting on elements, and taking a screenshot just has the side effect of giving it extra time to render. Without seeing code and the application, it's not really possible to offer any assistance.

On Thu, Jun 12, 2025, 7:28 PM Avram Eisner <avr...@gmail.com> wrote:
Our team is trying to switch from Webpack/Babble to Vite. In our Vite branch, many of our selenium tests are failing if it is run in headless mode. A weird fix is that if driver.get_screenshot_as_base64() is called before looking for the element it finds the element and passes. We would like to come up with a less hacky solution to this problem.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/selenium-users/40c06d28-6db1-4c57-b063-4f654b420ddbn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages