Testing mobile version of Bootstrap-based eCommerce site: Selenium script fails randomly

Hey everyone! I’m stuck with a tricky problem. We’ve got this eCommerce site built with Bootstrap and SAP. It works on desktops and mobiles. We’re using BrowserStack to test the mobile version with Selenium-Java scripts.

Here’s the issue: our tests keep failing at random spots. Sometimes it’s ‘Element not clickable’, other times ‘Element not found’ or ‘Element not accessible’. It’s driving us nuts!

We’ve tried using fluent waits (up to 50 seconds) for each element, but no luck. We know the site is async because of Bootstrap (v3.4.0) and SAP, while Selenium is sync. Fluent waits should handle this, right? But they’re not cutting it.

We’re on Selenium v4.16 and JDK 21. Any ideas what’s going on? Has anyone dealt with something like this before? We’re totally stumped here. Any help would be awesome!

I’ve encountered similar issues when testing responsive sites. One approach that helped was implementing a custom retry mechanism. Instead of relying solely on fluent waits, we created a method that attempts the action multiple times with short delays between tries. This can help overcome transient failures due to element reflows or AJAX updates.

Another tip: ensure your locators are robust and unique. With responsive designs, element attributes can change between desktop and mobile views. Using data-* attributes specifically for testing can provide more stable selectors across different viewports.

Lastly, consider running your tests at different viewport sizes. We found some issues only occurred at specific breakpoints. Systematically testing at various widths helped us isolate and fix layout-dependent bugs.

Hey DashingDog, sounds like a real headache! Have u considered using a JS executor to force interactions? Sometimes, especially with async stuff, that can bypass the ‘not clickable’ errors. Also, maybe try implementing a custom ExpectedCondition for element visibility and interactibility? That might help catch those sneaky timing issues. good luck!

Hey DashingDog, that sounds super frustrating! :tired_face: Have you thought about using a visual testing tool like Applitools or Percy? They can be game-changers for responsive sites. They capture screenshots at different breakpoints and compare them, which might help you spot where things are going wonky.

Also, I’m curious - are you using any specific mobile gestures in your tests? Sometimes touch events can be tricky to simulate. Maybe try a tool like Appium for better mobile support?

Oh, and random thought - could it be a network issue on BrowserStack? Sometimes their connections can be a bit flaky. Have you tried running the tests on a real device to see if you get the same random failures?

Keep us posted on what you find out! I’m really interested to hear what ends up solving this mystery. :man_detective: