Giter VIP home page Giter VIP logo

poltergeist-demo's Introduction

#Poltergeist

Poltergeist is a headess capybara driver based on PhantomJS. This project is a demonstration of Poltergiest driver in your project.

##Pre-requisite

in order to use Poltergeist, You must have PhatomJs installed. It's very easy to install.

On Mac : Use HomeBrew. Please note MacPort installtion is not recommended

          $ brew install phantomjs

On Linux : Download PhantomJS from the official site and add binary to your PATH [ Note 64 bit and 32 bit ]

            $ wget https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-x86_64.tar.bz2

And create symlink phantomjs/bin to your /usr/local/bin and /usr/bin

On Ubuntu, you can use basic phantomjs package like this

            $ sudo apt-get install phantomjs

#Usage

Note: You need to have Ruby 1.9.3 and Capybara 2.1.0 for the latest Poltergeist version. Please make sure you have Ruby 1.9.3 and Capybara 2.1.0 for this Demo.

Clone the repository

    $ git clone https://github.com/Shashikant86/Poltergeist-Demo.git
    $ cd Poltergeist-Demo

You may widh to do bundle update before running cucumber

    $ bundle update 

Now run cucumber to see all the scenario passes using Poltergiest.

    $ bundle exec cucumber

Now , if you got Ruby installed, you may need to check that Ruby version is compabtible with Poltergeist and Capybara version. If you got error then you can download Poltergeist gem by specifying Git repository. In order to do that you may need to update gemfile

     gem 'poltergeist', :git => 'git://github.com/jonleighton/poltergeist.git'

Playing with Poltergiest

There are many things you could do with poltergeist like resizing window, taking screenshot, capturing network traffic, response headers, cookie There are few option in the sinatra_step_definition file. You can comment out and see those in action

     #page.driver.resize(400,600)
     #page.save_screenshot("/Users/user/Desktop/test.pdf")
     #puts page.within_window
     #puts page.driver.network_traffic
     #puts page.driver.cookies
     #puts page.response_headers.to_a

Customising Poltergeist Options

You can customise Poltergeist with multiple options like JS error, debug, timeout and many more as mentioned on Poltergiest documentation Take a look at features/Support/env.rb file how options are configured. you can play with it by changing values or adding more options in the array e.g :debug => true

       Capybara.register_driver :poltergeist do |app|
       options = {
             :js_errors => false,
             :timeout => 120,
             :debug => false,
             :phantomjs_options => ['--load-images=no', '--disk-cache=false'],
             :inspector => true,

      Capybara::Poltergeist::Driver.new(app, options)
      end

poltergeist-demo's People

Contributors

shashikant86 avatar

Watchers

Pete avatar James Cloos avatar

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.