@juliemr is very active
But Why Do I Care?
Java
Javascript
driver.get(p1);
driver.click(E1);
driver.get(p1).then(function(){
driver.click(E1);
}
it('should find an element by text input model', function() {
browser.get('app/index.html#/form');
var username = element(by.model('username'));
username.clear();
username.sendKeys('Jane Doe');
var name = element(by.binding('username'));
expect(name.getText()).toEqual('Jane Doe');
// Point A
});
- At Point A, none of the tasks are executed yet. The browser.get method is in the front of the control flow queue, and the name.getText() call is at the back.
The value of name.getText() at Point A is an unresolved promise object.
driver.get("http://www.google.com").
then(function() {
return driver.findElement(By.name("q"));
}).
then(function(q) {
return q.sendKeys("webdriver");
}).
then(function() {
return driver.findElement(By.name("btnG"));
}).
then(function(btnG) {
return btnG.click();
}).
then(function() {
return driver.getTitle();
}).
then(function(title) {
assertEquals("webdriver - Google Search", title);
});
In your test
In your application
element(by.model("myModel"));
<input ng-model="myModel" />
In your test
In your application
element( by.repeater('user in users'));
<ul>
<li ng-repeat="user in users" class="a">
<li ng-repeat="user in users" class="b">
</li>
</ul>
expect(name.getText()).toEqual('Jane Doe');
Instead of this:
name.getText().then(function (name) {
expect(name).toEqual('jane Doe')
})
Do this:
describe(‘A suite’, function() {
it(‘contains spec with an expectation’, function() {
expect(true).toBe(true);
});
});
(via Node Package Manager)
Example - install Protractor
https://www.npmjs.com/package/protractor
In Terminal:
In our project:
- Creates 'Protractor' package in node-modules
Example - Install Protractor
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['angularPage-spec.js'],
capabilities: {
browserName: 'chrome',
'chromeOptions': {
'loggingPrefs': {
'browser': 'ALL'
}
}
};
protractor someConfFile.js
In the terminal:
Command
calc
browser.ignoreSynchronization = true;
settings form:
settings.js
Page object file
Page test file
function HomePage(url) {
this.url = url;
this.nameInput = element(by.model('yourName'));
}
HomePage.prototype.get = function() {
browser.get(this.url);
}
HomePage.prototype.setName = function(name) {
this.nameInput.sendKeys(name);
}
module.exports = HomePage;
var HomePage = require('../HomePage.js');
describe('HomePage Tests', function() {
var homePage = new HomePage('https://angularjs.org');
it('should verify homePage loads', function() {
homePage.get();
//...
}
}
protractor debug conf.js
browser.pause();
webdriver-manager start
2. Run the elementexplorer (project root) :
elem
.../protractor-example/node_modules/protractor/bin(master)$ ./elementexplorer.js someUrl