Coder Social home page Coder Social logo

bennylope / screenshooter Goto Github PK

View Code? Open in Web Editor NEW
51.0 9.0 8.0 71 KB

:camera: A tool for generating BrowserStack screenshots from the command line.

Home Page: http://benlopatin.com/blog/continuous-cross-browser-screenshots/

License: MIT License

Ruby 100.00%
ruby screenshots qa browserstack

screenshooter's Introduction

ScreenShooter!

A tool for generating BrowserStack screenshots from the command line.

Installing

gem install screenshooter

Or clone the repository and run

rake install

Configuration

You will need to provide username and authentication token credentials to use the service. You can do so with environment variables or using a file.

To use environment variables (suitable for a CI environment) set BROWSERSTACK_USERNAME and BROWSERSTACK_TOKEN, respectively. If these are missing then ScreenShooter will look for a credentials file.

You should set up your credentials in the .browserstack file in your home directory. It should look like this:

username:auth_token

Your authentication token is available under the automation section of your profile.

Next you'll need a browser configuration file. This will be used to specify which browser versions under which operating systems to take screenshots. You can start with the sample included in this project, sample_browsers.yaml or sample_browsers.json.

Using

For each URL provided, screenshooter will return a BrowserStack screenshot gallery URL.

General use is pretty straightforward:

screenshooter shoot path_to/browsers.yaml

If you are using a json file, then:

screenshooter shoot path_to/browsers.json

Once the request is successfully made, the program will return the URL of the screenshot collection. The URL output can be piped to another service.

Commands

screenshooter browsers list
screenshooter browsers search
screenshooter shoot

Arguments and options

screenshooter browsers list
screenshooter browsers search <SEARCH TERM>
screenshooter shoot -u <URL>
screenshooter shoot -u <URL> -u <URL> -u <URL>
screenshooter shoot -u <URL> -b <BROSWER JSON SPEC>

Setting the URL

You don't need to include the URL in your configuration file. It might be helpful if you're always taking screenshots of the same URL, but chances are you'll probably want to specify this each time you run the command.

screenshooter shoot path_to/browsers.yaml -u http://www.github.com

Waiting for completion

The command accepts an optional boolean flag, wait, which will check every 2.5 seconds on the status of the request and return the URL once the job is complete.

screenshooter shoot path_to/browsers.yaml -u http://www.github.com -w
screenshooter shoot path_to/browsers.yaml -u http://www.github.com --wait

Silence Progress bar

The command accepts an optional boolean flag, 'quiet', which will not print the progress bar, while using the 'wait' option. The screenshot URL will be printed once the job is complete

screenshooter shoot path_to/browsers.yaml -u http://www.github.com --wait -q
screenshooter shoot path_to/browsers.yaml -u http://www.github.com --wait -quiet

Open the screenshots URL

The command accepts an optional boolean flag, open, which will open the screenshots URL in your default browser.

screenshooter shoot path_to/browsers.yaml -u http://www.github.com -o
screenshooter shoot path_to/browsers.yaml -u http://www.github.com --open

screenshooter's People

Contributors

akhillb avatar bennylope avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

screenshooter's Issues

Add option to completely silence screenshooter.

Currently, option --wait makes screenshooter chatty. This is not ideal for Makefiles that are executed as make -j, where multiple calls to the screenshooter are processed in parallel.

So please add an option -q/--quiet to suppress any informational output.

Add option to emit plain text error messages

Right now, screenshooter emits an HTML page in case of error. This is hard to read in Makefile output, so please add an option to make screenshooter emit plain text error messages instead.

Getting 500/404 errors

When running screenshooter with the sample yml config I'm getting the following error(s):

$ BROWSERSTACK_USERNAME=<user> BROWSERSTACK_TOKEN=<token> screenshooter shoot browsers.yml {"code":"500","body":"<!DOCTYPE html>\n<html>\n<head>\n  <title>We're sorry, but something went wrong (500)</title>\n  <style type=\"text/css\">\n    body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }\n    div.dialog {\n      width: 25em;\n      padding: 0 4em;\n      margin: 4em auto 0 auto;\n      border: 1px solid #ccc;\n      border-right-color: #999;\n      border-bottom-color: #999;\n    }\n    h1 { font-size: 100%; color: #f00; line-height: 1.5em; }\n  </style>\n</head>\n\n<body>\n  <!-- This file lives in public/500.html -->\n  <div class=\"dialog\">\n    <h1>We're sorry, but something went wrong.</h1>\n    <p>We've been notified about this issue and we'll take a look at it shortly.</p>\n  </div>\n</body>\n</html>\n"}
/var/lib/gems/2.1.0/gems/browserstack-screenshot-0.0.2/lib/screenshot/client.rb:90:in `http_response_code_check': {"code":"404","body":"<!DOCTYPE html>\n<html>\n<head>\n  <title>The page you were looking for doesn't exist (404)</title>\n  <style type=\"text/css\">\n    body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }\n    div.dialog {\n      width: 25em;\n      padding: 0 4em;\n      margin: 4em auto 0 auto;\n      border: 1px solid #ccc;\n      border-right-color: #999;\n      border-bottom-color: #999;\n    }\n    h1 { font-size: 100%; color: #f00; line-height: 1.5em; }\n  </style>\n</head>\n\n<body>\n  <!-- This file lives in public/404.html -->\n  <div class=\"dialog\">\n    <h1>The page you were looking for doesn't exist.</h1>\n    <p>You may have mistyped the address or the page may have moved.</p>\n  </div>\n</body>\n</html>\n"} (Screenshot::UnexpectedError)
    from /var/lib/gems/2.1.0/gems/browserstack-screenshot-0.0.2/lib/screenshot/client.rb:70:in `make_request'
    from /var/lib/gems/2.1.0/gems/browserstack-screenshot-0.0.2/lib/screenshot/client.rb:52:in `http_get_request'
    from /var/lib/gems/2.1.0/gems/browserstack-screenshot-0.0.2/lib/screenshot/client.rb:32:in `screenshots_status'
    from /var/lib/gems/2.1.0/gems/screenshooter-0.0.3/lib/screenshooter.rb:56:in `shoot'
    from /var/lib/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /var/lib/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /var/lib/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /var/lib/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /var/lib/gems/2.1.0/gems/screenshooter-0.0.3/bin/screenshooter:5:in `<top (required)>'
    from /usr/local/bin/screenshooter:23:in `load'
    from /usr/local/bin/screenshooter:23:in `<main>'

Could not find task "./browsers.yaml".

I've installed on Ubuntu as per instructions and added the auth details to my env path and also as a file. When I run: screenshooter /var/www/browserstack/browsers.yaml I get Could not find task "/var/www/browserstack/browsers.yaml".

The file is readable with 777 privileges, and exists. screenshooter command lists the help options.

Any ideas?

Query: local testing

Hi,
Does the screenshooter works with browserstack local testing https://www.browserstack.com/local-testing?
I tried running the Browserstack local testing binary, then running the screenshooter script, but doesn't seem to work to screenshot our internal servers. Just wondering if this use case is not supported or something wrong in my setup.
Thanks,
Chen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.