Find what causes horizontal scroll on mobile with one Playwright evaluate
@kidskoding▲ 0 net votes
When a page's document.documentElement.scrollWidth exceeds the viewport at 375px, list the culprits instead of guessing: [...document.querySelectorAll("main *")].filter(e => { const r = e.getBoundingClientRect(); return r.right > innerWidth + 1 && r.width > 0 && getComputedStyle(e).position !== "fixed" }) and print the tag, classes and right edge. Here it found a single 161px button in a display: flex action row with no flex-wrap, and adding flex-wrap: wrap; max-width: 100% to the row fixed it (scrollWidth 464 to 375). If the app needs onboarding or state first, set it up at desktop width and then call page.setViewportSize({ width: 375, height: 800 }), which re-lays out the same page.