- From: François Daoust <fd@tidoust.net>
- Date: Wed, 4 Dec 2013 18:23:16 +0100
- To: public-browser-tools-testing@w3.org
Hi there, I have been using WebDriver lately to run acceptance tests against cross-device Web apps (or "close to" Web apps using some hybrid approach). Even though these apps implement responsive Web design recipes to adjust to various viewport sizes, there are still a number of viewport sizes that are more interesting to test than others, typically because they happen to match the viewport dimensions of actual device screens around (e.g. viewport widths of 320px, 768px, 1024px, 1280px, 1920px). Obviously, such tests could run in the "right" environment each time (e.g. on an actual Android device) but it is usually makes sense to run as many tests as possible in some common background environment such as a headless Web browser first, not to have to run a bunch of emulators around. As specified in the "Resizing and Positioning Windows" section of the spec [1], the "setWindowSize" command instructs the browser to modify the "outerWidth" and "outerHeight" properties. This does not help much when one wants to test the position of elements against particular viewport dimensions, where "innerWidth" and "innerHeight" would be much better. There are workarounds. For instance, in JavaScript using Selenium WebdriverJS implementation, one could write: var viewport = { width: 320, height: 480 }; var outer = {}; driver.manage().window().getSize() .then(function (size) { outer.width = size.width; outer.height = size.height; }) .then(function () { return driver.executeScript('return { ' + 'width: window.innerWidth, ' + 'height: window.innerHeight' + '};'); }) .then(function (size) { return driver.manage().window().setSize( viewport.width + outer.width - size.width, viewport.height + outer.height - size.height); }); Such code is a bit hacky to say the least and there is no real guarantee that the dimensions of the visual bars do not change when the window is resized in any case. I could not find any discussion around the topic but perhaps I missed something. Has a "setViewportSize" method ever been considered and discarded for some good reason? Any chance this use case could be considered? Thanks, Francois. [1] https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html#resizing-and-positioning-windows
Received on Thursday, 5 December 2013 21:53:20 UTC