SlideShare a Scribd company logo
https://mvc.tw
歡迎參加我們的每週四固定聚會
1
如何測試與保護你的 Web Application
with Playwright
阿砮 Cheng-Ju Wu
https://mvc.tw
2
End-to-End Test ?
開始前…如果我是測試工程師
https://mvc.tw
3
End-to-End Test
https://mvc.tw
End-to-End Test
4
脆弱性
Timeout
工人智慧
重複工作
Trace Log
環境問題
耗時
成本
https://mvc.tw
End-to-End Test
5
▪ 繁瑣又缺乏創造力
▪ 時間成本
▪ 開發維護成本
▪ 執行慢
▪ 測試覆蓋率低
▪ 可靠性
如何改善
提升效率
https://mvc.tw
6
切入主題
https://mvc.tw
Agenda
▪ What is Playwright
▪ Why choose Playwright
▪ How to use Playwright
▪ Use cases
7
https://mvc.tw
8
What is Playwright
https://mvc.tw
What is Playwright
9
github.com/microsoft/playwright
Playwright Playwright Test
https://mvc.tw
Playwright is
▪ Bowser Automation Framework
▪ Node.js Library
▪ Open Source
▪ Puppeteer
▪ By Microsoft
10
github.com/microsoft/playwright
https://mvc.tw
Playwright is
▪ Cross-platform ( Windows, Linux, macOS )
▪ Cross-browser testing with single API
▪ Supports 3 browser engines
▪ Chromium:Google Chrome / Microsoft Edge / Opera
▪ Firefox
▪ WebKit:Apple Safari
11
playwright.dev github.com/microsoft/playwright
https://mvc.tw
Playwright can't
▪ 與實際落差
▪ 無法操作手機,只能開啟手機瀏覽器模擬模式
▪ WebKit 與 Safari 差異
12
github.com/microsoft/playwright
https://mvc.tw
Playwright is
▪ Cross-language
▪ TypeScript / JavaScript
▪ .NET
▪ Python
▪ Java
13
playwright.dev
https://mvc.tw
Playwright
JavaScript
14
https://mvc.tw
Playwright
Python
15
https://mvc.tw
Playwright
Java
16
https://mvc.tw
Playwright
.NET
17
https://mvc.tw
Playwright is
18
https://mvc.tw
19
Playwright is
https://mvc.tw
Playwright Test
▪ Test Runner
▪ Reporters
▪ Parallelism
▪ Test Retries
▪ …
20
https://mvc.tw
21
Playwright: Browser Contexts
https://mvc.tw
22
Playwright: Browser Contexts
▪ Not Restart a Browser
▪ 完整隔離的環境
▪ 快速實例化
▪ 較低的資源開銷
https://mvc.tw
23
Playwright: Browser Contexts
https://mvc.tw
24
Playwright: Auto-waiting
▪ 簡化測試程式,有助於聚焦實際任務
▪ 不太需要手動寫下 wait 來確保前端收到回應
▪ 提高測試可靠性
▪ 因應現今網站,頻繁存取後端 API 的特性
▪ 執行操作前對 Element 可操作性檢查
https://mvc.tw
25
Playwright: Auto-waiting
https://mvc.tw
26
Why choose Playwright
https://mvc.tw
Why choose Playwright
27
https://mvc.tw
28
Playwright Selenium
Browsers Chromium, Firefox, and WebKit
Chrome, Firefox, IE, Edge, Opera, Safari, and
more
Language
Java, Python, C#
JavaScript, Typescript
Java, Python, C#
JavaScript,
Ruby, Perl, PHP
Installation Easy to Install Easy to Install
Prerequisites NodeJS Java, Browser Drivers
OS Supported Windows, Linux, and Mac OS Windows, Linux, Solaris, and Mac OS
Open Source Open Source and Free Open Source and Free
Architecture
Headless Browser with event-driven
architecture
Layered Architecture based on JSON Wire
Protocol
Real Devices Support
Does not support real devices
but supports emulators
Supports real device clouds and remote
servers
https://mvc.tw
IDE
29
https://mvc.tw
30
How to use Playwright
https://mvc.tw
Playwright Install
▪ Node.js
▪ .NET
31
https://mvc.tw
Playwright
▪ Download browsers
32
https://mvc.tw
Playwright
▪ Record videos
▪ Screenshots
33
https://mvc.tw
Playwright
▪ Code generator and debugger
▪ Intercept network
34
https://mvc.tw
CSS Seletors
Sample Code
35
https://mvc.tw
36
CSS Selectors
w3schools CSS Selectors
https://mvc.tw
Playwright
▪ Inspector
▪ Debugging Playwright scripts
37
https://mvc.tw
38
Demo
https://mvc.tw
是否發生過,一句話惹怒…
39
網站反應很慢
怎麼慢法 ?
大約回應多久
https://mvc.tw
Playwright
▪ Trace Viewer
▪ Recording trace
▪ Viewing trace
▪ Action
▪ Screenshots
▪ Snapshots
40
https://mvc.tw
41
Demo
https://mvc.tw
42
Getting started with .NET
https://mvc.tw
Getting started with .NET
43
https://mvc.tw
44
Demo Code
https://mvc.tw
Getting started with .NET
45
https://mvc.tw
46
Use Cases
https://mvc.tw
47
Network – Abort Requests
https://mvc.tw
48
什麼情況下需要用到 Abort Requests
https://mvc.tw
49
Network – Abort Requests
▪ Ads-blocker
https://mvc.tw
50
Demo Code
https://mvc.tw
Network
Abort Requests
Ads-blocker
Sample Code
51
https://mvc.tw
52
Network – Abort Request
▪ 網站新手提示
novice-guide-demo From 黑暗執行緒
https://mvc.tw
53
Demo Code
https://mvc.tw
Network
Abort Requests
網站新手提示
Sample Code
54
https://mvc.tw
55
Authentication
https://mvc.tw
Authentication
56
測試執行時間
總計執行時間
登入次數
https://mvc.tw
Authentication
57
https://mvc.tw
58
Demo Code
https://mvc.tw
59
總結
https://mvc.tw
總結 End-to-End Test ( RD & QA )
▪ 提升開發效率 => 透過現代化工具
▪ 提升溝通效率 => 透過 Trace Log
▪ 提升測試效率 => 透過 Network Abort Requests
▪ 目標關注在真正需要測試的內容: Ads-blocker / 網站新手提示
▪ 降低重複性過多的步驟: Authentication
60
https://mvc.tw
61
參考資料
https://mvc.tw
參考資料
▪ Playwright.dev
▪ microsoft/playwright
62
Blog 是記錄知識的最佳平台
63
https://dotblogs.com.tw
64
SkillTree 為了確保內容與實務不會脫節,我們都是聘請企業顧問等級
並且目前依然在職場的業界講師,我們不把時間浪費在述說歷史與沿革,
我們並不是教您考取證照,而是教您如何上場殺敵,拳拳到肉的內容才
是您花錢想要聽到的,而這也剛好是我們擅長的。
https://skilltree.my
65
天瓏資訊圖書

More Related Content

What's hot (20)

PPTX
MicrometerとPrometheusによる LINEファミリーアプリのモニタリング
LINE Corporation
 
PPTX
實現 Angular, Docker 與 Kubernetes 持續部署 (NG+2020)
Will Huang
 
PPTX
[2022 DevOpsDays Taipei] 走過 DevOps 風雨的下一步
Edward Kuo
 
PDF
SFUの話
tnoho
 
PDF
twMVC#44 讓我們用 k6 來進行壓測吧
twMVC
 
PDF
Windowsフォームで大丈夫か?一番良いのを頼む。
Yuya Yamaki
 
PPTX
Stac2021 [初学者向け]ローコード開発におけるテストの考え方
Satoshi Sakashita
 
PDF
モノタロウの開発・リリースサイクルを支えるJenkinsの活用事例 - Jenkins Day Japan 2021
株式会社MonotaRO Tech Team
 
PDF
人生がときめくAPIテスト自動化 with Karate
Takanori Suzuki
 
PDF
【BS14】Blazor WebAssemblyとJavaScriptのインターオペラビリティ
日本マイクロソフト株式会社
 
PDF
[Cloud OnAir] Anthosで実現するハイブリッドクラウド 〜 GKE On-Prem編 〜 2019年8月29日 放送
Google Cloud Platform - Japan
 
PDF
ユニットテストの保守性を作りこむ, xpjugkansai2011
H Iseri
 
PPTX
The twelve factor app
Ravi Okade
 
PDF
모바일 앱(App) 개발 테스트 솔루션 v20160415
SeungBeom Ha
 
PDF
Quarkus k8s
Georgios Andrianakis
 
PPTX
reg-suitとQA Wolfを活用したVisual Regression Test
Kazuyuki Tsuzisaki
 
PPT
Web Test Automation with Selenium
vivek_prahlad
 
PDF
Riverpodでテストを書こう
Shinnosuke Tokuda
 
PPT
Spring Framework
nomykk
 
PPTX
プログラミング言語の比較表
Kazunori Sakamoto
 
MicrometerとPrometheusによる LINEファミリーアプリのモニタリング
LINE Corporation
 
實現 Angular, Docker 與 Kubernetes 持續部署 (NG+2020)
Will Huang
 
[2022 DevOpsDays Taipei] 走過 DevOps 風雨的下一步
Edward Kuo
 
SFUの話
tnoho
 
twMVC#44 讓我們用 k6 來進行壓測吧
twMVC
 
Windowsフォームで大丈夫か?一番良いのを頼む。
Yuya Yamaki
 
Stac2021 [初学者向け]ローコード開発におけるテストの考え方
Satoshi Sakashita
 
モノタロウの開発・リリースサイクルを支えるJenkinsの活用事例 - Jenkins Day Japan 2021
株式会社MonotaRO Tech Team
 
人生がときめくAPIテスト自動化 with Karate
Takanori Suzuki
 
【BS14】Blazor WebAssemblyとJavaScriptのインターオペラビリティ
日本マイクロソフト株式会社
 
[Cloud OnAir] Anthosで実現するハイブリッドクラウド 〜 GKE On-Prem編 〜 2019年8月29日 放送
Google Cloud Platform - Japan
 
ユニットテストの保守性を作りこむ, xpjugkansai2011
H Iseri
 
The twelve factor app
Ravi Okade
 
모바일 앱(App) 개발 테스트 솔루션 v20160415
SeungBeom Ha
 
reg-suitとQA Wolfを活用したVisual Regression Test
Kazuyuki Tsuzisaki
 
Web Test Automation with Selenium
vivek_prahlad
 
Riverpodでテストを書こう
Shinnosuke Tokuda
 
Spring Framework
nomykk
 
プログラミング言語の比較表
Kazunori Sakamoto
 

Similar to twMVC#44 如何測試與保護你的 web application with playwright (16)

PDF
Playwright For Test Automation _ A Step by Step Guide.pdf
Steve Wortham
 
PPTX
PlayWright Training - PlayWright Automation Training.pptx
himavanthvisualpath
 
PDF
No drama here - E2E-testing django with playwright
Mastacheata1
 
PDF
Writing Maintainable Playwright Tests with Ease
Shubham Joshi
 
PDF
Getting Started with Playwright: A Beginner-Friendly Introduction & Setup Guide
Shubham Joshi
 
PDF
Why Should we use Microsoft's Playwright
Knoldus Inc.
 
PDF
Playwright Testing Guide for QA Engineers.pdf
jamescantor38
 
PDF
playwrightmeetup-14jan2021-210114173639.pdf
ManjuBiradar6
 
PDF
Playwright: An Emerging Tool in Test Automation
Anna Royzman
 
PDF
playwrithgttttttttttttttttttttttSlides.pdf
SarvjeetKumarSingh1
 
PDF
Leveraging Playwright for API Testing.pdf
Steve Wortham
 
PPTX
Playwright Online Training | Playwright Automation Testing Hyderabad
Jayanthvisualpath
 
PDF
"Playwright can do this? An intro into e2e testing and Playwright", Stefan Ju...
Fwdays
 
PPTX
UI Test Automation With Playwright with Pytest
Arshad QA
 
PDF
GlobalLogic Test Automation Online TechTalk “Playwright — A New Hope”
GlobalLogic Ukraine
 
PDF
Introducing Playwright's New Test Runner
Applitools
 
Playwright For Test Automation _ A Step by Step Guide.pdf
Steve Wortham
 
PlayWright Training - PlayWright Automation Training.pptx
himavanthvisualpath
 
No drama here - E2E-testing django with playwright
Mastacheata1
 
Writing Maintainable Playwright Tests with Ease
Shubham Joshi
 
Getting Started with Playwright: A Beginner-Friendly Introduction & Setup Guide
Shubham Joshi
 
Why Should we use Microsoft's Playwright
Knoldus Inc.
 
Playwright Testing Guide for QA Engineers.pdf
jamescantor38
 
playwrightmeetup-14jan2021-210114173639.pdf
ManjuBiradar6
 
Playwright: An Emerging Tool in Test Automation
Anna Royzman
 
playwrithgttttttttttttttttttttttSlides.pdf
SarvjeetKumarSingh1
 
Leveraging Playwright for API Testing.pdf
Steve Wortham
 
Playwright Online Training | Playwright Automation Testing Hyderabad
Jayanthvisualpath
 
"Playwright can do this? An intro into e2e testing and Playwright", Stefan Ju...
Fwdays
 
UI Test Automation With Playwright with Pytest
Arshad QA
 
GlobalLogic Test Automation Online TechTalk “Playwright — A New Hope”
GlobalLogic Ukraine
 
Introducing Playwright's New Test Runner
Applitools
 
Ad

More from twMVC (20)

PDF
twMVC#51 以平台工程重新思考系統設計 - 以 Batch System 為例封面
twMVC
 
PDF
twMVC#51-GitHub Copilot 徹底改變開發模式,探索 AI 驅動的智慧程式碼協作
twMVC
 
PDF
twMVC#50 微服務上線後的救贖
twMVC
 
PDF
twMVC 47_Elastic APM 的兩三事
twMVC
 
PDF
twMVC#46_SQL Server 資料分析大躍進 Machine Learning Services
twMVC
 
PDF
.NET 7 家族新成員: Microsoft Orleans v7
twMVC
 
PDF
twMVC#46 一探 C# 11 與 .NET 7 的神奇
twMVC
 
PDF
twMVC#43 Visual Studio 2022 新功能拆解
twMVC
 
PDF
twMVC#43 YARP
twMVC
 
PDF
twMVC#43 C#10 新功能介紹
twMVC
 
PDF
twMVC#42 Azure DevOps Service Pipeline設計與非正常應用
twMVC
 
PDF
twMVC#42 Azure IoT Hub for Smart Factory
twMVC
 
PDF
twMVC#42 Windows容器導入由0到1
twMVC
 
PDF
twMVC#42 讓我們用一種方式來開發吧
twMVC
 
PDF
twMVC#41 hololens2 MR
twMVC
 
PPTX
twMVC#41 The journey of source generator
twMVC
 
PDF
twMVC#38 How we migrate tfs to git(using azure dev ops)
twMVC
 
PDF
twMVC#36C#的美麗與哀愁
twMVC
 
PDF
twMVC#36.NetCore 3快速看一波
twMVC
 
PDF
twMVC#36讓 Exceptionless 存管你的 Log
twMVC
 
twMVC#51 以平台工程重新思考系統設計 - 以 Batch System 為例封面
twMVC
 
twMVC#51-GitHub Copilot 徹底改變開發模式,探索 AI 驅動的智慧程式碼協作
twMVC
 
twMVC#50 微服務上線後的救贖
twMVC
 
twMVC 47_Elastic APM 的兩三事
twMVC
 
twMVC#46_SQL Server 資料分析大躍進 Machine Learning Services
twMVC
 
.NET 7 家族新成員: Microsoft Orleans v7
twMVC
 
twMVC#46 一探 C# 11 與 .NET 7 的神奇
twMVC
 
twMVC#43 Visual Studio 2022 新功能拆解
twMVC
 
twMVC#43 YARP
twMVC
 
twMVC#43 C#10 新功能介紹
twMVC
 
twMVC#42 Azure DevOps Service Pipeline設計與非正常應用
twMVC
 
twMVC#42 Azure IoT Hub for Smart Factory
twMVC
 
twMVC#42 Windows容器導入由0到1
twMVC
 
twMVC#42 讓我們用一種方式來開發吧
twMVC
 
twMVC#41 hololens2 MR
twMVC
 
twMVC#41 The journey of source generator
twMVC
 
twMVC#38 How we migrate tfs to git(using azure dev ops)
twMVC
 
twMVC#36C#的美麗與哀愁
twMVC
 
twMVC#36.NetCore 3快速看一波
twMVC
 
twMVC#36讓 Exceptionless 存管你的 Log
twMVC
 
Ad

Recently uploaded (20)

PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
July Patch Tuesday
Ivanti
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 

twMVC#44 如何測試與保護你的 web application with playwright