Prompt
How do I run the same end-to-end suite on mobile web
Latest observation
To run the same end-to-end suite on mobile web, you usually keep the tests the same and change the browser context / viewport / user agent to emulate a mobile device.
Common approach
1) Run the suite in a mobile-emulated browser
Use a desktop browser with mobile emulation:
- smaller viewport
- touch input
- mobile user agent
- device scale factor
This is the easiest way to reuse the same E2E tests.
2) Point the suite at the mobile web app
If your app has a separate mobile URL or responsive behavior, configure your test base URL accordingly.
3) Parameterize your test run
Create separate configs for:
- desktop web
- mobile web
Then run the same specs against both.
Examples by test framework
Playwright
import { devices } from '@playwright/test';
export default defineConfig({
projects: [
{
name: 'Desktop Chrome',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'Mobile Safari',
use: { ...devices['iPhone 13'] },
},
],
});
Run:
npx playwright test
Cypress
describe('mobile web', () => {
beforeEach(() => {
cy.viewport('iphone-6');
});
it('runs the same flow', () => {
cy.visit('/');
// same test steps
});
});
Selenium
Set the browser window size and mobile user agent, or use device emulation through Chrome DevTools Protocol.
Best practices
- Prefer responsive selectors that work on both desktop and mobile.
- Avoid assumptions about hover, right-click, or large-screen layouts.
- Make waiting/assertions robust for slower mobile rendering.
- If possible, run on real mobile browsers in addition to emulation.
If you mean real devices
Use a cloud device farm or lab:
- BrowserStack
- Sauce Labs
- LambdaTest
- Firebase Test Lab
That lets you execute the same suite on actual iPhones/Android devices.
If you tell me which framework you use—Playwright, Cypress, Selenium, or something else—I can show the exact setup.