Git Product home page Git Product logo

protractor's Introduction

Protractor

Protractor is an end to end test framework for Angular applications built on top of WebDriverJS.

Protractor can be run as a standalone binary runner, or included into your tests as a library. Use Protractor as a library if you would like to manage WebDriver and your test setup yourself.

For more information, read the docs, or head over to the FAQ.

To run the sample tests

Install protractor with.

npm install protractor

Start up a selenium server (See the appendix below for help with this). By default, the tests expect the selenium server to be running at http://localhost:4444/wd/hub.

The example folder contains multiple versions of a simple test suite which runs against angularjs.org.

onJasmineNodeSpec.js and onMocha.js show how to use the Protractor library with jasmine-node and mocha. Run these with:

jasmine-node example/onJasmineNodeSpec.js
mocha example/onMocha.js

You can also run the example suite using the Protractor runner. The runner accepts a configuration file, which runs the tests at example/onProtractorRunner.js.

bin/protractor example/protractorConf.js

Using the Protractor runner

The Protractor runner is a binary which accepts a config file. The Protractor runner runs tests written in Jasmine, but other adapters may be added in the future.

Install protractor with

npm install protractor

Create a configuration file - an example is shown in node_modules/protractor/referenceConf.js.

cp node_modules/protractor/referenceConf.js myConf.js

Edit the configuration file to point to your tests.

exports.config = {
  jasmineNodeOpts: {
    specs: ['myTest.js', 'myFolder/myOtherTest.js']
  }
}

The configuration file must also specify a way of connection to webdriver. This can be

  • seleniumAddress: The address of a running selenium standalone server.
  • seleniumServerJar: The location of the selenium standalone .jar file on your machine. Protractor will use this to start up the selenium server.
  • sauceUser and sauceKey: The username and key for a SauceLabs account. Protractor will use this to run tests on SauceLabs.

Run with

node_modules/.bin/protractor myConf.js

Or, if you installed protractor globally (using npm install -g protractor)

protractor myConf.js

When using the runner, the protractor library is exported to the global namespace as protractor. The current instance can be grabbed with ptor = protractor.getInstance().

Using the Protractor library

Use the Protractor library if you would like to manage webdriverJs yourself.

Install protractor with

npm install protractor

In your test, set up a webdriver instance, then wrap it with protractor.

var protractor = require('protractor');
var driver;
// Set up driver as a webdriver however you'd like.
var ptor = protractor.wrapDriver(driver);

Cloning and running Protractor's own tests

Clone the github repository.

git clone https://github.com/angular/protractor.git
cd protractor
npm install

Start up a selenium server. By default, the tests expect the selenium server to be running at http://localhost:4444/wd/hub.

Protractor's test suite runs against the included testapp. Start that up with

cd testapp
./scripts/web-server.js

Then run the tests with

npm test

Appendix A: Setting up a standalone selenium server

WebdriverJS does not natively include the selenium server - you must start a standalone selenium server. All you need is the latest selenium-server-standalone.

To use with chrome browsers, download chromedriver. More information about chromedriver

A script is included to do the download for you - run (add the --nocd option if you do not want to install ChromeDriver)

./node_modules/protractor/bin/install_selenium_standalone

Start the selenium standalone with

./selenium/start

For alternate ways to download and start the selenium standalone, see the webdriver docs.

protractor's People

Contributors

buthrakaur avatar colinmutter avatar danielflower avatar davemo avatar jeffbcross avatar jnizet avatar juliemr avatar marcenuc avatar yangchenyun avatar

Watchers

 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.