1

I have a responsive webpage that I need to test at different resolutions to inspect the layout at these different resolutions. Is there a command line option that I can use to open one webpage in a bunch of different windows, each with a different resolution like the following?

enter image description here

I'd love to somehow figure out how to do this without opening a bunch of new windows and then adjusting each of them every time with the Window Resizer extension.

migrated from webapps.stackexchange.com Jun 19 at 22:37

This question came from our site for power users of web applications.

  • Hi Ross, questions about installable software are off-topic here on Web Applications. I am going to migrate this to Super User for that reason. I have also edited out the request for an extension aspect, because that's off-topic on both of the sites. – jonsca Jun 19 at 22:37
  • Did you try chrome bundle, from google, there is some options that can be useful for you. – Archil Labadze Jun 19 at 22:47
1

I wrote a script called many_resolutions.py which is used like:

python many_resolutions.py http://localhost:3000 800x600,0,0 1280x1024,2000,0

Where the screen spec is <width>x<height>,<x-position>,<y-position>.

import subprocess, sys, os

CHROME='/usr/bin/google-chrome-stable'
webpage = sys.argv[1]
for screen_spec in sys.argv[2:]:
    split = screen_spec.split(',')
    if len(split) not in (1,3) or 1 > split[0].find('x'): 
        raise Exception('Screen arguments are <width>x<height>,<x-position>,<y-position>')
    screen_res = split[0].split('x')
    pos = None
    if len(split) == 3:
        pos = split[1:3]
    cmd = [
        CHROME,
        '--profile-directory=Default',
        '--app=data:text/html,<html><body><script>' +
        ('window.moveTo(' + pos[0] +',' + pos[1] + ');' if pos else '') +
        'window.resizeTo(' + screen_res[0] + ',' + screen_res[1] + ');' +
        'window.location="' + webpage + '";</script></body></html>',
    ]
    print(cmd)
    subprocess.Popen(cmd, preexec_fn=os.setpgrp)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.