Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
chore(syntax): update all other specs to the new syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
juliemr committed Oct 27, 2013
1 parent a2cd6c8 commit 267d49d
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 63 deletions.
10 changes: 4 additions & 6 deletions spec/altRoot/findelements_spec.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
var util = require('util');

describe('finding elements when ng-app is nested', function() {
var ptor;

describe('in forms', function() {
ptor = protractor.getInstance();

beforeEach(function() {
ptor.get('app/alt_root_index.html#/form');
browser.get('app/alt_root_index.html#/form');
});

it('should find an element by binding', function() {
var greeting = ptor.findElement(protractor.By.binding('{{greeting}}'));
var greeting = element(by.binding('{{greeting}}'));

expect(greeting.getText()).toEqual('Hiya');
});

it('should find elements outside of angular', function() {
var outside = ptor.findElement(protractor.By.id('outside-ng'));
var inside = ptor.findElement(protractor.By.id('inside-ng'));
var outside = element(by.id('outside-ng'));
var inside = element(by.id('inside-ng'));

expect(outside.getText()).toEqual('{{1 + 2}}');
expect(inside.getText()).toEqual('3');
Expand Down
13 changes: 6 additions & 7 deletions spec/login/viaConfigConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@ exports.config = {
},

onPrepare: function() {
var ptor = protractor.getInstance();
ptor.driver.get('http://localhost:8000/app/login.html');
browser.driver.get('http://localhost:8000/app/login.html');

ptor.driver.findElement(protractor.By.id('username')).sendKeys('Jane');
ptor.driver.findElement(protractor.By.id('password')).sendKeys('1234');
ptor.driver.findElement(protractor.By.id('clickme')).click();
browser.driver.findElement(by.id('username')).sendKeys('Jane');
browser.driver.findElement(by.id('password')).sendKeys('1234');
browser.driver.findElement(by.id('clickme')).click();

// Login takes some time, so wait until it's done.
// For the test app's login, we know it's done when it redirects to
// index.html.
ptor.wait(function() {
return ptor.driver.getCurrentUrl().then(function(url) {
browser.driver.wait(function() {
return browser.driver.getCurrentUrl().then(function(url) {
return /index/.test(url);
});
});
Expand Down
12 changes: 3 additions & 9 deletions spec/login/viaConfigSpec.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
describe('pages with login', function() {
var ptor;

beforeEach(function() {
ptor = protractor.getInstance();
})

it('should log in with a non-Angular page', function() {
ptor.get('http://localhost:8000/app/index.html');
browser.get('http://localhost:8000/app/index.html');

var angularElement = ptor.findElement(protractor.By.input('url'));
var angularElement = element(by.input('url'));
expect(angularElement.getAttribute('value')).toEqual('/fastcall');

// Make sure the cookie is still set.
ptor.manage().getCookie('testcookie').then(function(cookie) {
browser.manage().getCookie('testcookie').then(function(cookie) {
expect(cookie.value).toEqual('Jane-1234');
});
});
Expand Down
26 changes: 10 additions & 16 deletions spec/login/viaTestSpec.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,33 @@
describe('pages with login', function() {
var ptor;

beforeEach(function() {
ptor = protractor.getInstance();
})

it('should log in with a non-Angular page', function() {
ptor.driver.get('http://localhost:8000/app/login.html');
browser.driver.get('http://localhost:8000/app/login.html');

ptor.driver.findElement(protractor.By.id('username')).sendKeys('Jane');
ptor.driver.findElement(protractor.By.id('password')).sendKeys('1234');
ptor.driver.findElement(protractor.By.id('clickme')).click();
browser.driver.findElement(by.id('username')).sendKeys('Jane');
browser.driver.findElement(by.id('password')).sendKeys('1234');
browser.driver.findElement(by.id('clickme')).click();

// Login takes some time, so wait until it's done.
// For the test app's login, we know it's done when it redirects to
// index.html.
ptor.wait(function() {
return ptor.driver.getCurrentUrl().then(function(url) {
browser.wait(function() {
return browser.driver.getCurrentUrl().then(function(url) {
return /index/.test(url);
});
});

// The login should have set a cookie. Make sure it's there.
ptor.manage().getCookie('testcookie').then(function(cookie) {
browser.manage().getCookie('testcookie').then(function(cookie) {
expect(cookie.value).toEqual('Jane-1234');
});


ptor.get('http://localhost:8000/app/index.html');
browser.get('http://localhost:8000/app/index.html');

var angularElement = ptor.findElement(protractor.By.input('url'));
var angularElement = element(by.input('url'));
expect(angularElement.getAttribute('value')).toEqual('/fastcall');

// Make sure the cookie is still set.
ptor.manage().getCookie('testcookie').then(function(cookie) {
browser.manage().getCookie('testcookie').then(function(cookie) {
expect(cookie.value).toEqual('Jane-1234');
});
});
Expand Down
18 changes: 3 additions & 15 deletions spec/onPrepare/onPrepare_spec.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
describe('tests that use the shortcuts set by the onPrepare in the config',
describe('onPrepare function in the config',
function() {
beforeEach(function() {
// ptor is in the globals thanks to the onPrepare callback function in the
// config.
ptor.get('app/index.html#/form');
});

it('should find an element using elem instead of findElement', function() {
var greeting = ptor.elem(protractor.By.binding('{{greeting}}'));
expect(greeting.getText()).toEqual('Hiya');
});

it('should find an element using the global by function', function() {
var greeting = ptor.elem(by.binding('{{greeting}}'));
expect(greeting.getText()).toEqual('Hiya');
it('should have a special variable set in onPrepare', function() {
expect(browser.params.password).toEqual('12345');
});
});
6 changes: 1 addition & 5 deletions spec/onPrepare/startup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
var ptor = protractor.getInstance();
ptor.elem = ptor.findElement;
ptor.elems = ptor.findElements;
global.by = protractor.By;
global.ptor = ptor;
browser.params.password = '12345';
6 changes: 1 addition & 5 deletions spec/onPrepareConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ exports.config = {
baseUrl: 'http://localhost:8000',

onPrepare: function() {
var ptor = protractor.getInstance();
ptor.elem = ptor.findElement;
ptor.elems = ptor.findElements;
global.by = protractor.By;
global.ptor = ptor;
browser.params.password = '12345';
}
};

0 comments on commit 267d49d

Please sign in to comment.