Ideal
Actualprotractor.conf.js
Test,Scripts
Selenium,Server
Browser,Drivers
$ npm install protractor
Setup
$ npm install protractor
Setup
$ npm install yo$ sudo ynpm i -g generator-ypr -otractor$ cd your-repo-dir$ yo yprotractor:existing$ ynpm update
$ npm install protractor
Setup
package.json
}, "devDependencies": { "less": "1.7.3", "jslint": "0.5.2", "mojito-cli": "0.1.2", "yahoo-arrow": "~0.5.1", "yhint": "*", "chai": "^1.9.0", "chai-as-promised": "^4.1.0", "mocha": "^1.19.0", "protractor": "1.1.x", "protractor-utils": "0.2.x" },
$ npm install yo$ sudo ynpm i -g generator-ypr -otractor$ cd your-repo-dir$ yo yprotractor:existing$ ynpm update
$ npm install protractor
Setup
package.json
}, "devDependencies": { "less": "1.7.3", "jslint": "0.5.2", "mojito-cli": "0.1.2", "yahoo-arrow": "~0.5.1", "yhint": "*", "chai": "^1.9.0", "chai-as-promised": "^4.1.0", "mocha": "^1.19.0", "protractor": "1.1.x", "protractor-utils": "0.2.x" },
$ npm install yo$ sudo ynpm i -g generator-ypr -otractor$ cd your-repo-dir$ yo yprotractor:existing$ ynpm update
$ git clone xxx.git && cd xxx$ ynpm i
$ npm install webdriver-manager
$ webdriver-manager update --standalone$ webdriver-manager start
Setup
$ npm install protractor
$ git clone xxx.git && cd xxx$ ynpm i
$ webdriver-manager status
$ npm install yo$ sudo ynpm i -g generator-ypr -otractor$ cd your-repo-dir$ yo yprotractor:existing$ ynpm update
$ npm install protractor
$ git clone xxx.git && cd xxx$ ynpm i
$ protractor tests/spec/ protractor.conf.js -- seleniumAddress="..." -- baseUrl="..."
protractor.conf.js
Run
$ npm install protractor
$ git clone xxx.git && cd xxx$ ynpm i
$ protractor tests/spec/ protractor.conf.js -- seleniumAddress="..." -- baseUrl="..."
Run
Using the selenium server at http://10.82.57.93:4444/wd/hub1..2ok 1 Page onload test should match store titlenot ok 2 Universal header shoppingcart checking after click items... ...
# tests 2# pass 1# fail 1
mocha Chai%Asser*on%LibraryProtractor API 1.3.0
Test,Scripts
mocha Chai%Asser*on%LibraryProtractor API 1.3.0
describe('Page onload test', function () {
it('should match store title', function () {
});
});
mocha Chai%Asser*on%LibraryProtractor API 1.3.0
describe('Page onload test', function () {
it('should match store title', function () {
});
});
browser.get('/');
/* global browser, $, it, describe, before */
browser.getTitle()
mocha Chai%Asser*on%LibraryProtractor API 1.3.0
describe('Page onload test', function () {
it('should match store title', function () {
});
});
expect( ).to.eventually.equal('����');
var chai = require(‘chai’), expect = chai.expect, chaiAsPromised = require(‘chai-as-promised’);
chai.use(chaiAsPromised);
browser.get('/');
/* global browser, $, it, describe, before */
browser.getTitle()
Chai%Asser*on%Librarymocha Protractor API 1.3.0
describe('Page onload test', function () {var node, present;
it('store logo should exist', function () {
node = element(by.css(‘.ylogo’));present = node.isPresent();console.log(‘present: ’, present);expect(present).to.equal(true);
});});
Chai%Asser*on%Librarymocha Protractor API 1.3.0
describe('Page onload test', function () {var node, present;
it('store logo should exist', function () {
node = element(by.css(‘.ylogo’));present = node.isPresent();console.log(‘present: ’,present);expect(present).to.eveutually.equal(true);node.isPresent().then(function (_present) {
console.log(‘_present: ’, _present);expect(_present).to.equal(true);
}); });});
Chai%Asser*on%Librarymocha Protractor API 1.3.0
describe('Page onload test', function () {var node, present;
it('check if link works', function () {
node = $(‘.ylogo’);node.getAttribute('href').then(function (_linkUrl) {
browser.getCurrentUrl().then(function (curUrl) { expect(_curUrl).to.contain(_linkUrl);
}).then(function () {
node.click(); });
browser.wait(function () { return browser.getCurrentUrl().then(function (_curUrl) {
return _curUrl === _linkUrl; }, TIMELIMIT);
}); });});
Chai%Asser*on%Librarymocha Protractor API 1.3.0
describe('Page onload test', function () {var node, present;
it('check if link works', function () {
node = $(‘.ylogo’);node.getAttribute('href').then(function (_linkUrl) {
linkUrl = _linkUrl;return browser.getCurrentUrl();
}).then(function (curUrl) { expect(_curUrl).to.contain(_linkUrl);}).then(function () {
node.click(); .then(function () {
browser.wait(function () { return browser.getCurrentUrl().then(function (_curUrl) {
return _curUrl === linkUrl; }, TIMELIMIT);
}); });});
Chai%Asser*on%Librarymocha Protractor API 1.3.0
describe('Page onload test', function () {var node, present;
it('check if link works', function () {
node = $(‘.ylogo’);protractor.promise.all([browser.getCurrentUrl(), node.getAttribute('href')]).then(function (_res) {
curUrl = _res[0];linkUrl = _res[1];node.click();browser.wait(function () {
return browser.getCurrentUrl().then(function (_curUrl) {
return _curUrl === linkUrl;}, TIMELIMIT);
}); });});
Tips
describe.only('Test task A', function () {
it('sub-task 1', function () {});it('sub-task 2', function () {});
});
describe('Test task B', function () {it('sub-task 1', function () {});
});
describe('Test task C', function () {it.only('sub-task 1', function () {});it('sub-task 2', function () {});
});
describe('Test task D', function () {it('sub-task 1', function () {});it('sub-task 2', function () {});
});
only skip
Tips
only%only%is%only
onlydescribe.only('Test task A', function () {
it.skip('sub-task 1', function () {});it('sub-task 2', function () {});
});
describe('Test task B', function () {it('sub-task 1', function () {});
});
describe.only('Test task C', function () {it.skip('sub-task 1', function () {});it.skip('sub-task 2', function () {});it('sub-task 2', function () {});
});
describe('Test task D', function () {it('sub-task 1', function () {});
});
skip
Tips$ protractor tests/spec/protractor.conf.js --seleniumAddress="..." --baseUrl="..." --specs=tests/spec/test/universal.spec.js --suite=uni
protractor.conf.js
after
Tips
describe.only('Test task A', function () {var hambgNode;beforeEach(function () { hambgNode = $('.header .myStore ');});it('sub-test 1', function () {});it('sub-test 2', function () {});
});
describe('Test task B', function () {beforeEach(function () { hambgNode = $('.header .myStore ');});it('sub-test 1', function () {});
});
before beforeEach afterEach
Source
mochaChai%Asser*on%LibraryProtractor API 1.3.0
Top Related