[Feature] How to use setMobileEmulation for correct window resize · Issue #310 · google/webdriver.dart · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to fix flutter/issues/136109 in Flutter for proper window size and E2E screenshot comparison. I realised that the same resize behaviour in ordinary Selenium WebDriver script, but if I adding setMobileEmulation all become correct. But I can't find the same feature here. Can you validate my thought, maybe this feature already supported in Dart version.
import{Builder}from'selenium-webdriver';importchromefrom'selenium-webdriver/chrome.js';import{existsSync,mkdirSync,writeFileSync}from'fs';constoptions=newchrome.Options();options.addArguments('--no-sandbox');// BUG FIX >>> options.setMobileEmulation({deviceMetrics: {width: 393,height: 852,pixelRatio: 3.0},userAgent: 'Mozilla/5.0 (Linux; Android 15) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.200 Mobile Safari/537.36'});// <<<constdriver=newBuilder().forBrowser('chrome').usingServer('http://localhost:4444')// Ensure this server is running.setChromeOptions(options).build();(asyncfunctiontakeScreenshot(){try{// Set the window size to match the emulated deviceawaitdriver.manage().window().setRect({width: 393,height: 852});// Create the screenshots directory if it doesn't existif(!existsSync('screenshots')){mkdirSync('screenshots');}// Take a screenshot and save itconstscreenshot=awaitdriver.takeScreenshot();writeFileSync('screenshots/screenshot.png',screenshot,'base64');}catch(error){console.error('An error occurred:',error);}finally{awaitdriver.quit();}})();
The text was updated successfully, but these errors were encountered:
I wanted to fix flutter/issues/136109 in Flutter for proper window size and E2E screenshot comparison. I realised that the same resize behaviour in ordinary Selenium WebDriver script, but if I adding setMobileEmulation all become correct. But I can't find the same feature here. Can you validate my thought, maybe this feature already supported in Dart version.
The text was updated successfully, but these errors were encountered: