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
(Extension DC 2025) Actor境界を越える技術
teamhimeh
1
260
組込みだけじゃない!TinyGo で始める無料クラウド開発入門
otakakot
0
290
Introducing ReActionView: A new ActionView-Compatible ERB Engine @ Kaigi on Rails 2025, Tokyo, Japan
marcoroth
3
1k
他言語経験者が Golangci-lint を最初のコーディングメンターにした話 / How Golangci-lint Became My First Coding Mentor: A Story from a Polyglot Programmer
uma31
0
180
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
400
Catch Up: Go Style Guide Update
andpad
0
230
Devvox Belgium - Agentic AI Patterns
kdubois
1
120
Pull-Requestの内容を1クリックで動作確認可能にするワークフロー
natmark
2
510
20251016_Rails News ~Rails 8.1の足音を聴く~
morimorihoge
2
380
CSC305 Lecture 05
javiergs
PRO
0
220
After go func(): Goroutines Through a Beginner’s Eye
97vaibhav
0
400
monorepo の Go テストをはやくした〜い!~最小の依存解決への道のり~ / faster-testing-of-monorepos
convto
2
500
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
514
110k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Music & Morning Musume
bryan
46
6.8k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
620
Facilitating Awesome Meetings
lara
56
6.6k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.5k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
53k
How to train your dragon (web standard)
notwaldorf
97
6.3k
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.6k
Automating Front-end Workflow
addyosmani
1371
200k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
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! -