@juliemr is very active
driver.get(page1);
driver.click(E1);
driver.get(page1).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);
});
expect(name.getText()).toEqual('Jane Doe');
name.getText().then(function (name) {
expect(name).toEqual('jane Doe')
})
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>
element(by.css('#searchBtn')) === $('#searchBtn')
Selenium
Jasmine
describe(‘A suite’, function() {
it(‘contains spec with an expectation’, function() {
expect(true).toBe(true);
});
});
Test Structure
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
(*at this point presenting live demo)
Example - install Protractor
In Terminal
Example - Install Protractor
In our project:
- Creates 'Protractor' package in node-modules
Example - Install Protractor
browser.ignoreSynchronization = true;
settings.js
Hotel BO Settings
Page object file
Page test file
Using the
protractor-infrastructure project
ElementProxy.js (protractor-infrastructure)
Test file
wrapper for selenium method
Ask me anything :)