This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// protractor_chrome_conf.js | |
exports.config = { | |
seleniumAddress: 'http://127.0.0.1:4444/wd/hub', | |
capabilities: { | |
'browserName': 'chrome' | |
}, | |
suites: { | |
homepage: ['test/e2e/homepage/homepage.spec.js'], | |
location: ['test/e2e/location/circulating.spec.js', | |
'test/e2e/location/research.spec.js'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// location.spec.js | |
describe('Locations: Schwarzman Building', function () { | |
beforeEach(function () { | |
browser.get('/schwarzman'); | |
// Wait for the AngularJS app to load before testing DOM elements. | |
browser.waitForAngular(); | |
}); | |
it('should display the branch\'s name on the page', function () { | |
var name = element(by.css('.location-name')); | |
// Assertion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// location.po.js | |
var LocationPage = function () { | |
this.name = element(by.css('.location-name')); | |
this.street_address = element(by.binding('location.street_address')); | |
// ... | |
}; | |
module.exports = new LocationPage(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// updated location.spec.js | |
describe('Locations', function () { | |
var locationPage = require('./location.po.js'); | |
it('should display the research branch\'s name on the page', function () { | |
browser.get('/schwarzman'); | |
browser.waitForAngular(); | |
expect(locationPage.name.getText()).toEqual('Stephen A. Schwarzman Building'); | |
expect(locationPage.street_address.getText()).toEqual('Fifth Avenue at 42nd Street'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Google Analytics: pageview tracking', function () { | |
var landingPage = require('../homepage/homepage.po.js'); | |
function mockGA() { | |
return "window.ga_msg = [];" + | |
"ga = function () {" + | |
" var msg = [];" + | |
" for (var i = 0; i < arguments.length; i++) {" + | |
" msg.push(arguments[i]); " + | |
" }" + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var landingPage = require('../homepage/homepage.po.js'); | |
it('should track branch searching near the user', function () { | |
landingPage.geolocation.click(); | |
browser.executeScript('return window.ga_msg;').then(function (ga) { | |
expect(ga[0][2]).toEqual('Locations'); | |
expect(ga[0][3]).toEqual('Filter by'); | |
expect(ga[0][4]).toEqual('Near me'); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var httpBackendMock = function (response) { | |
var API_URL = 'url_for_the_api'; | |
angular | |
.module('httpBackendMock', ['ngMockE2E']) | |
.run(function ($httpBackend) { | |
$httpBackend | |
.whenJSONP(API_URL + '/locations/grand-central?callback=JSON_CALLBACK') | |
.respond(response); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Research branch page', function () { | |
'use strict'; | |
var locationPage = require('./location.po.js'), | |
// Mocked API response for a research library. | |
APIresponse = require('../APImocks/research.js'), | |
httpBackendMock = function (response) { | |
// Defined above | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run only once | |
$ ./node_modules/protractor/bin/webdriver-manager update | |
# Run everytime to start the Selenium Server | |
$ ./node_modules/protractor/bin/webdriver-manager start | |
# To run all tests | |
$ protractor protractor_chrome_conf.js | |
# To run a specific section |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Geolocation', function () { | |
var landingPage = require('./homepage.po.js'); | |
function mockGeo(lat, lon) { | |
return 'window.navigator.geolocation.getCurrentPosition = ' + | |
' function (success, error) {' + | |
' var position = {' + | |
' "coords" : {' + | |
' "latitude": "' + lat + '",' + | |
' "longitude": "' + lon + '"' + |
OlderNewer