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
タスクの特性や不確実性に応じた最適な作業スタイルの選択(ペアプロ・モブプロ・ソロプロ)と実践 / Optimal Work Style Selection: Pair, Mob, or Solo Programming.
honyanya
3
160
Le côté obscur des IA génératives
pascallemerrer
0
140
私達はmodernize packageに夢を見るか feat. go/analysis, go/ast / Go Conference 2025
kaorumuta
2
520
その面倒な作業、「Dart」にやらせませんか? Flutter開発者のための業務効率化
yordgenome03
1
110
Software Architecture
hschwentner
6
2.3k
クラシルを支える技術と組織
rakutek
0
200
Domain-centric? Why Hexagonal, Onion, and Clean Architecture Are Answers to the Wrong Question
olivergierke
2
810
GraphQL×Railsアプリのデータベース負荷分散 - 月間3,000万人利用サービスを無停止で
koxya
1
1.2k
ソフトウェア設計の実践的な考え方
masuda220
PRO
4
550
CSC305 Lecture 03
javiergs
PRO
0
240
Go Conference 2025: Goで体感するMultipath TCP ― Go 1.24 時代の MPTCP Listener を理解する
takehaya
9
1.6k
技術的負債の正体を知って向き合う / Facing Technical Debt
irof
0
150
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
45
7.7k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.4k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.7k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
900
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.7k
Making the Leap to Tech Lead
cromwellryan
135
9.6k
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.6k
Mobile First: as difficult as doing things right
swwweet
224
10k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
61k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
620
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! -