Skip to content

Commit

Permalink
bit of general cleanup and removing embarrassments...
Browse files Browse the repository at this point in the history
  • Loading branch information
qualityshepherd committed Aug 1, 2017
1 parent a926e6a commit 6d880c6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
8 changes: 5 additions & 3 deletions README.md
@@ -1,11 +1,13 @@
[ ![Codeship Status for qualityshepherd/protractor-example](https://app.codeship.com/projects/56e27ab0-abb1-0132-4f48-46f15878b48e/status?branch=master)](https://app.codeship.com/projects/68348)

# Protractor Example #
# Protractor Example
Herein lies an example [Protractor](http://protractortest.org) project, that includes tests (some quite silly) that aim to illustrate solutions for common issues when writing e2e tests.

## Example Protractor project that:
* Makes use of page objects
* Runs tests on [Sauce Labs](http://saucelabs.com)
* Runs multiple browsers at once
* Runs tests sharded (parallel)
* Includes examples tests for both Angular, and non-Angular applications
* Uses [protractor-flake](https://github.com/NickTomlin/protractor-flake) to re-run failed tests
* is written using es6
Expand All @@ -14,11 +16,11 @@
* Install [Node](http://nodejs.org) (v6.x.x or later)
* `git clone https://github.com/qualityshepherd/protractor_example`
* `npm install` to install the project dependencies
* `node_modules/.bin/webdriver_manager update` to update drivers
* `node_modules/.bin/webdriver_manager update` to update drivers (this _should_ be run automagically on install)

## Run tests:
* run tests `npm test` (runs via flake, which re-runs failed tests)
* run tests via plain Protractor `node_modules/.bin/protractor conf.js`
* run tests `npm test` (runs via flake, which re-runs failed tests)
* run with flake `./flake conf.js`
* run on saucelabs`./flake sauceConf.js` (add your username/key)

Expand Down
7 changes: 2 additions & 5 deletions pages/friendPage.js
Expand Up @@ -66,14 +66,11 @@ class FriendsPage extends BasePage {

/**
* delete all friends
* @return {[type]}
*/
deleteAllFriends() {
//this.deleteButtons.click();
let buttons = this.deleteButtons;
buttons.count().then(count => {
this.deleteButtons.count().then(count => {
while(count > 0) {
buttons.get(0).click();
this.deleteButtons.get(0).click();
count--;
}
});
Expand Down
2 changes: 1 addition & 1 deletion pages/nonAngularLoginPage.js
Expand Up @@ -21,7 +21,7 @@ class LoginPage extends BasePage {
* @return {[type]} [description]
*/
loginAs(userObj) {
this.login(userObj.username, userObj.password);
return this.login(userObj.username, userObj.password);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion pages/qsHomePage.js
Expand Up @@ -43,7 +43,7 @@ class QsHomePage extends BasePage {
* @return {bool}
*/
findPostByPaging(postTitle) {
this.postTitleExists(postTitle).then(found => {
return this.postTitleExists(postTitle).then(found => {
if(found) {
// found it!
return true;
Expand Down
8 changes: 4 additions & 4 deletions specs/friendSpec.js
Expand Up @@ -4,23 +4,24 @@
import friendPage from '../pages/friendPage';
import Chance from 'chance';
const chance = new Chance();
const EXISTING_NAME = 'Paul';

describe ('angular app', () => {
beforeEach(() => {
friendPage.goto();
});

it('should add a new friend', () => {
const FRIEND_NAME = chance.first();
const FRIEND_NAME = chance.first(); // random first name
friendPage.addFriend(FRIEND_NAME);

expect(friendPage.inResults(FRIEND_NAME)).toBe(true);
});

it('should delete an existing friend', () => {
friendPage.deleteFriend('Paul');
friendPage.deleteFriend(EXISTING_NAME);

expect(friendPage.inResults('Paul')).toBe(false);
expect(friendPage.inResults(EXISTING_NAME)).toBe(false);
});

it('should not display non-found search terms', () => {
Expand All @@ -30,7 +31,6 @@ describe ('angular app', () => {
});

it('should display found search terms', () => {
const EXISTING_NAME = 'Paul';
friendPage.searchFor(EXISTING_NAME);

expect(friendPage.inResults(EXISTING_NAME)).toBe(true);
Expand Down
2 changes: 1 addition & 1 deletion specs/nonAngularLoginSpec.js
Expand Up @@ -22,6 +22,6 @@ describe ('non-angular login', () => {
it('should goto friend pages on successful login', () => {
loginPage.loginAs(userData.testUser);

expect(friendPage.loaded()).toBeTruthy();
expect(friendPage.loaded()).toBe(true);
});
});

0 comments on commit 6d880c6

Please sign in to comment.