npm install -g generator-ptor
mkdir projectName && cd projectName
yo ptor "ProjectName"
or
yo ptor
If you dont pass a name then package.json will take a generic name for the app. Yeoman will ask if you would like to user CoffeScript. If you say yes the sample and configuration files will be adapted for CoffeeScript.
This script is actually doing the following steps:
1- Install all dependencies
npm install
2- Install selenium standalon server and chrome driver (./bin/install.sh)
./node_modules/protractor/bin/webdriver-manager update
protractor.conf.js protractor-sauce.conf.js
yo ptor:spec "TestName"
Yeoman will generate the file TestNameSpec.js under specs folder.
If you already have a CoffeeScript inside your Spec folder, then Yeoman will create a coffeescript pageObject for you. If you dont and you would like to force the coffeescript creation, you may run:
yo ptor:spec "TestName" --coffee
yo ptor:page "PageName"
If you already have a CoffeeScript inside your pageObjects folder, then Yeoman will create a coffeescript pageObject for you. If you dont and you would like to force the coffeescript creation, you may run:
yo ptor:page "PageName" --coffee
1- Make sure your application is running 2- Run
grunt test
This script is actually doing the following steps:
1- Start selenium server
./bin/selenium-server.sh
2- Running protractor
./bin/test.sh
Note: Depending on your machine sometimes the test starts running before the selenium server actually started. If this occurs to you, then on one terminal tab run:
./bin/selenium-server.sh
Wait for the server to come up and on a second tab:
./bin/test.sh
1- Update the protractor-sauce.conf.js adding your user and key provided by Sauce Labs. 2- From your command line run
grunt test-sauce
This script is actually doing the following steps:
1- ./bin/test-sauce.sh
The configuration is in Gruntfile.js where we create two parallel executions with different arguments. Example:
sauce: {
tasks: [
{cmd: "./bin/test-sauce.sh", args: ['--capabilities.browserName=safari']},
{cmd: "./bin/test-sauce.sh", args: ['--capabilities.browserName=firefox']}
]
}
1- Make sure protractor-sauce.conf.js contains the user/key for sauce labs. 2- From Jenkins' job command line
grunt test-sauce-browser --browser=safari
This is only one possibility. Read the following do to analyze all options. https://github.com/angular/protractor/blob/master/docs/debugging.md
- Open Run/Debug Configurations dialog
- Add new Node.js configuration
- On Configuration tab set:
- Path to Node: path to node executable . e.g. '/usr/bin/node'
- Working directory: your project base path e.g. '/usr/sesteva/temp'
- Path To Node JS App file: path to Protractor cli.js file (e.g. node_modules\protractor\lib\cli.js)
- Application parameters: path to your Protractor configuration file (e.g. protractorConfig.js)
- Click OK, place some breakpoints on your js files.
- Click on Debug from the Run menu.
The only difference would be to just set the breakpoints on the generated JS files under .tmp folder
We could setup multiple jobs each one running on a different browser. This provides granular feedback and the benefit of running in parallel.
Job 1:
grunt test-sauce-browser --browser=safari
Job 2:
grunt test-sauce-browser --browser=firefox
We could have a unique job running on multiple browsers.
grunt test-sauce
sudo npm link
sudo npm ls --global generator-ptor
sudo npm rm --global generator-ptor