yauhen kavaliou andrei palchys “we don’t need qa anymore” or protractor

36

Upload: polly-lynch

Post on 20-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor
Page 2: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Yauhen Kavaliou

Andrei Palchys

“We don’t need QA anymore”or

Protractor

Page 3: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Sencha Touch 2

Cordova

5+ products (phone/tablet & ios/android)

+3 years and 150k LoC

Project

Page 4: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

2 small teams

7 developers

5 manual QA

4 automation testers

Team

Page 5: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Many changes every release

Developers produces more code than QA (Manual and Auto) can test in 2 week sprint.

There is a misbalance in maturity between Devs and QA

Page 6: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Experiment

One dev team will develop and cover features with automation tests

Automation tests will be written based on QA tests cases.

Page 7: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Selenium WebDriver

Page 8: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Test WebDriver BrowserAPI

Page 9: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

JSON wire protocol

POST /session/12345567890/url{ "url" : "http://rollingscopes.com/" }

Page 10: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

ChromeDriver

FirefoxDriver

InternetExplorerDriver

SafariDriver

GhostDriver

Page 11: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Appium

Page 12: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Protractor is an end-to-end test framework for AngularJS JavaScript applications.

Page 13: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

describe('rollingscopes.com', function () { it('check meetup name', function () { browser.get('http://rollingscopes.com'); var text = element(by.css('.banner h1')).getText(); expect(text).toEqual('The Rolling Scopes #19'); });});

Protractor provides nice abstraction on top of WebDriver API and uses Jasmine as a test

framework

Page 14: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

The WebDriver Control Flow

var text = element(by.css('.banner h1')).getText();expect(text).toEqual('The Rolling Scopes #19');

You write async code in sync way

Page 15: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Google Chrome and ChromeDriver

Page 16: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Jasmine

Suits and Specs

Page 17: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

describe( 'Suit Name' , function(){ /*specs*/ })it( 'Spec Name' , function(){ /*expect*/ }, timeout)expect(a).toBe(b)

.not.toBe(b)

.toBeGreaterThan(b)

.toBeLessThan(b)

.toEqual(b)

.toBeDefined()

.toMatch(/\d+/g)…

Page 18: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Approaches

- “Smart” automated tests- User as a config

Page 19: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

{login: 'user' ,password: 'password' ,preferences: {

hasAccessToFeatures: false,isAdmin: true,hasAnalytics: false

},navigation: [ 'home' , ‘settings' ]

}

Page 20: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

var specs = {

setup: './Base/spec/Setup.js',

complete: './Base/spec/Complete.js'

};

module.exports = {

specs: specs,

mandatory: [specs.setup, specs.login],

full: [

specs.setup,

{ name: specs.home, allowed: '*', disabled: ['multipleDeals'] },

specs.settings,

specs.complete

]

}

Page 21: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Page Object

Page 22: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Before

describe(‘angularjs homepage', function() { it('should greet the named user', function() { browser.get('http://www.angularjs.org'); element(by.model('yourName')).sendKeys('Julie'); var greeting = element(by.binding('yourName')); expect(greeting.getText()).toEqual('Hello Julie!'); });});

Page 23: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Afterdescribe('angularjs homepage', function() { it('should greet the named user', function() {

var angularHomepage = new AngularHomepage(); angularHomepage.get(); angularHomepage.setName('Julie');

expect(angularHomepage.getGreeting()).toEqual('Hello Julie!');

Page 24: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Promises

Page 25: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Basecomponentsviewsutilspec

Project1componentsconfigspecviews

Project2componentsconfigspecviews

Page 26: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

browser.executeScript(string|Function, args)

browser.executeScriptAsync(string|Function, args)

Page 27: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Utils- WaitFor method based on ExpectedConditions

- Touch interactions and scrolling based on mouseEvents и scriptExecute

- Specific methods for Sencha Touch, for example - scroll to selected Record and e.t.c.

Page 28: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

var EC = protractor.ExpectedConditions;

exports.waitFor = function (selector, time) {

return browser.wait(EC.presenceOf(element(by.css(selector))), time || 10000);

}

exports.waitForVisibility = function (selector, time) {

return browser.wait(EC.visibilityOf(element(by.css(selector))), time || 10000);

}

exports.waitForHidden = function (selector, time) {

return browser.wait(EC.invisibilityOf(element(by.css(selector))), time || 10000);

}}

Page 29: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

11:06:19.472 INFO - Executing: [find elements: By.cssSelector: .main-container])11:06:19.479 INFO - Done: [find elements: By.cssSelector: .main-container]11:06:19.484 INFO - Executing: [is enabled: 17 [[ChromeDriver: chrome on XP (fb89e8300a09af71aa37b0b5041c8052)] -> css selector: .main-container]])11:06:19.490 INFO - Done: [is enabled: 17 [[ChromeDriver: chrome on XP (fb89e8300a09af71aa37b0b5041c8052)] -> css selector: .main-container]]

...it('App is ready' , function() { //Util.waitFor(this.CSS.container) mainView.waitForLoading();

//browser.isElementPresent(by.css(this.CSS.container)) expect(mainView.isPresent()).toBe(true);

});...

Page 30: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

xtype supportby.xtype = function (xtype) {

return {

findElementsOverride: function (driver, using, rootSelector) {

return driver.findElements( by.xpath( '//div[contains(@id,"' + xtype + '")] | //form[contains(@id,"' + xtype + '")]' ), rootSelector);

},

toString: function toString() {

return 'by.xtype("' + xtype + '")';

}

};

};

Page 31: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Timeouts

• { allScriptTimeout : timeout }

• browser.manage().timeouts().implicitlyWait(timeout)

• jasmineNodeOpts.defaultTimeoutInterval = timeout it ('Spec Name', function(){ /*expect*/ }, timeout)

Page 32: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

browser.sleep(timeout)

Page 33: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Plugins

- Screenshot reporter - Console- Report…

Page 34: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Issues- Different speed of executing on different environments

- Tough to debug- Why did my test fail?-WebDriver crashes

-DOM manipulations in real-time

- Invisible items

Page 35: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Debug

Node-inspector

Page 36: Yauhen Kavaliou Andrei Palchys “We don’t need QA anymore” or Protractor

Conclusions