Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Testing Angular apps with Protractor
Search
Tomohiro Akutsu
June 18, 2017
Programming
0
1.3k
Testing Angular apps with Protractor
angularを使用したwebアプリケーションにおけるE2Eテストに関するスライドです。また、こちらは2017年6月16日に行われたD-cubeの資料となっています。
Tomohiro Akutsu
June 18, 2017
Tweet
Share
Other Decks in Programming
See All in Programming
CA.swift19 恋するAIアプリ開発の裏側
oskmr
0
360
AWS Application Composerで始める、 サーバーレスなデータ基盤構築 / 20240406-jawsug-hokuriku-shinkansen
kasacchiful
1
260
初心者のためのRubyKaigi入門/RubyKaigi Introduction
a_matsuda
1
520
GraphQLサーバの構成要素を整理する #ハッカー鮨 #tsukijigraphql / graphql server technology selection
izumin5210
4
840
Netty Chicago Java User Group 2024-04-17
sullis
0
180
Goのmultiple errorsについて (2024年4月版)
syumai
3
870
Git Rebase
bkuhlmann
11
1.6k
Apache Hive 4 on Treasure Data
ryukobayashi
0
320
OpenAPIを中心に考えるAPI開発入門 / Introduction to API Development with a Focus on OpenAPI
seike460
PRO
2
170
エンターテイメント業界で利用されるAWS
demuyan
0
210
冗長なエラーログを削減し、スタックトレースを手に入れる / Reducing Verbose Error Logs and Obtaining Stack Traces
upamune
0
730
雑に思考を整理する技術と効能
konifar
60
29k
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
7
1k
Principles of Awesome APIs and How to Build Them.
keavy
121
16k
How To Stay Up To Date on Web Technology
chriscoyier
782
250k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
2
3.4k
Happy Clients
brianwarren
92
6.4k
Testing 201, or: Great Expectations
jmmastey
28
6.4k
The Language of Interfaces
destraynor
151
23k
A Tale of Four Properties
chriscoyier
151
22k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
9
8.3k
Building Effective Engineering Teams - LeadDev
addyosmani
28
1.8k
In The Pink: A Labor of Love
frogandcode
138
21k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
501
140k
Transcript
Testing ɹngular apps with Protractor June 2017 v.1.0.0 Tomohiro Akutsu
Front-end Engineer BizReach, Inc. June 16 2017 @Bizreach, Inc.
Introduce Myself - ࣗݾհ -
## Introduce Myself Tomohiro Akutsu Ѩٱஐେ @TomohiroAkutsu HRMOS Div. BizReach,
Inc. Front-end Engineer
Introduce Our Product - )3.04ͷհ -
## Introduce Our Product https://hrmos.co/
Agenda - ຊ͓͢Δ͜ͱ -
## Agenda ### E2E Testing and Protractor ### Install and
Setup ### API/Usage ### Resource of Learning 1SPUSBDUPSͷ֓ཁ 1SPUSBDUPSͷΠϯετʔϧɺ$POGKTͷهड़ ༻ҙ͞Ε͍ͯΔ"1*ه๏ ࠓޙɺΑΓࣝΛਂΊΔ͋ͨͬͯ
Do not Talk - ຊ͓͠ͳ͍͜ͱ -
## Do not Talk ### Unit Testing of Front-end ###
Comparison with Other Testing Framework ϑϩϯτΤϯυʹ͓͚ΔϢχοτςετ ଞͷςετπʔϧͱͷൺֱݕ౼
E2E Testing and Protractor - Protractorͷ֓ཁ -
## Introduce Protractor http://www.protractortest.org/#/
## Introduce Protractor https://github.com/angular/protractor
## Overview of Protractor ɾ1SPUSBDUPSثͷҙຯΛ࣋ͭ ɾͪͳΈʹBOHVMBS֯ͷ͋ΔΈ͍ͨͳҙຯ ɾBOHVMBS ֯ Λςετ ଌΔ
͢Δ1SPUSBDUPS ث ɾ/PEFKT͔Β4FMFOJVNΛѻ͏ϥΠϒϥϦͱͯ͠8FC%SJWFS+4Λར༻
## Built on top of WebDriverJS https://www.thoughtworks.com//insights/blog/testing-angularjs-apps-protractor
Install and Setup - ProtractorͷΠϯετʔϧɺConf.jsͷهड़ -
## Install OQNͰ1SPUSBDUPSΛΠϯετʔϧ npm install protractor QSPUSBDUPS XFCESJWFSNBOBHFSίϚϯυ͕͑ΔΑ͏ʹͳΔɻ 4FMFOJVN8FC%SJWFSΛϩʔΧϧڥΠϯετʔϧ webdriver-manager
update αʔόʔͷىಈ webdriver-manager start IUUQMPDBMIPTUXEIVCͷΞΫηε͕ՄೳʹͳΔɻ
## Example QBDLBHFKTPOͷTDSJQUTʹهड़ “scripts”: { … “test”: “protractor ./test/protractor/conf.js”, “webdriver”:
“webdriver-manager update && webdriver-manager start”, … } ίϚϯυͰςετͷ࣮ߦ͕Մೳɻҙͱͯͦ͠ΕͧΕผλϒͰ։͘͜ͱɻ
## Setup DPOGKTʹ֤छઃఆΛهड़ɹhttps://github.com/angular/protractor/blob/master/lib/config.ts export.config = { seleniumAddress: ‘http://localhost:4444/wd/hub’, capabilities: {
‘browserName’: ‘chrome’ }, specs: [spec.js], baseUrl: ‘http://localhost:9000/’, jasminNodeOpts: { showColors: true, defaultTimeoutInterval: 30000 } };
API/Usage - ༻ҙ͞Ε͍ͯΔAPIه๏ -
Basic Example - spec.jsͷجຊతͳߏจ -
## Basic Example spec.js describe(‘this test description is Hoge.’, function()
{ it(‘Fuga in Hoge’, function() { browser.get(‘https://angular.io/’); expect(browser.getTitle()).toEqual(‘Angular Docs’); }); it(‘Piyo in Hoge’, function() { … }); });
Global Variables - άϩʔόϧม -
## browser browser.get(‘url’) var baseUrl = ‘http://localhost:3000’; … browser.get(baseUrl +
‘/path/’); expect(browser.getTitle()).toEqual(‘This page title is Hoge’); browser.waitForAngular() browser.waitForAngular();
## element, by <p class=“name”>My name is {{person.name}}.</p> <input type=“text”
ng-model=“person.name”> var input = element(by.model(‘person.name’)); input.sendKeys(‘Tomohiro’); expect(element(by.css(‘p.name’)).getText()).toEqual(‘…is Tomohiro.’); element(by.model(‘modelName’)); <ul> <li>Blue</li> <li>Green</li> <li>Yellow</li> </ul> var yellow = element(by.cssContainingText(‘li’, ‘Yellow’)); element(by.cssContainingText(‘cssSelector’, ‘searchString’));
## element, by <ul ng-repeat=“item in items”> <li>{{item.name}}</li> </ul> element(by.repeater(‘item
in items’)).row(0).column(‘name’); element(by.repeater(‘repeatDescriptor’)); <a href=“url” class=“button”>Click</a> var button = element(by.className(‘button’)); expect(button.getText()).toEqual(‘Click’); button.click(); element(by.className(‘className’));
Handling Events - Πϕϯτͷॲཧ -
## Handling Events .click(); <button ng-click=“submit()”>submit</button> element(by.css(‘[ng-click=“submit()”]’)).click(); sendKeys(); var inputMail
= element(by.model(‘modelName’)); inputText.sendKeys(‘
[email protected]
’, protractor.Key.ENTER);
Resource of Learning - ࠓޙΑΓࣝΛਂΊΔ͋ͨͬͯ -
## Resource of Learning ɾެࣜυΩϡϝϯτ ɾ(JU)VC ɾ1SPUSBDUPS"OHVMBS+4ͷ࣍ੈ&&ςετϑϨʔϜϫʔΫ ɾ"OHVMBS+4ʹ&&ςετڥͱͯ͠1SPUSBDUPSΛಋೖ͢Δɻ
Thank You for Listening. - Let’s Work Together! -