SmartClient Version: SNAPSHOT_v13.1d_2024-09-05/AllModules Development Only (built 2024-09-05)
Hello, I'm trying to emulate different devices with cypress. Despite its limitations, I think it could be useful for finding issues—at least major ones related to viewport size, like when an element is not visible.
To emulate different devices, I'm using this code in my test:
It works fine with isc.Browser.isTablet, but unfortunately, isc.Page.getOrientation() always returns 'landscape'.
Is this something that can be fixed in your Cypress integration, or am I out of luck in this scenario?
Hello, I'm trying to emulate different devices with cypress. Despite its limitations, I think it could be useful for finding issues—at least major ones related to viewport size, like when an element is not visible.
To emulate different devices, I'm using this code in my test:
Code:
const deviceOrientation = 'portrait'; // const deviceOrientation = 'landscape'; const device = 'ipad-mini'; // const device = 'ipad-air'; // const device = 'desktop'; const DEVICE_CONFIGS = { 'ipad-mini': { userAgent: 'Mozilla/5.0 (iPad; CPU OS 9_3_5 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13G36 Safari/601.1', width: 768, height: 1024, visitUrl: '/Jat' }, 'ipad-air': { userAgent: 'Mozilla/5.0 (iPad; CPU OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15A5341f Safari/604.1', width: 820, height: 1180, visitUrl: '/Jat' } }; let setUserAgentAndViewport = function (config, orientation) { const {width, height} = config; if (orientation === 'landscape') { cy.viewport(height, width); } else { cy.viewport(width, height); } cy.visit(config.visitUrl, { onBeforeLoad: (win) => { Object.defineProperty(win.navigator, 'userAgent', { value: config.userAgent, }); } }); cy.window().then((win) => { win.dispatchEvent(new Event('resize')); }); }; ... setUserAgentAndViewport(DEVICE_CONFIGS[device], deviceOrientation);
Is this something that can be fixed in your Cypress integration, or am I out of luck in this scenario?
Comment