Skip to content

cythilya/nightwatch101

Repository files navigation

Nightwatch101

手牽手一起來學 Nightwatch!

Nightwatch.js

安裝

簡易安裝步驟如下。

Step 1:安裝 Java Development Kit(JDK)

安裝 Java Development Kit(JDK),至少版本 7 以上。(適用 Windows 和 macOS)

在 Linux 用 apt 安裝:

sudo apt install openjdk-8-jdk # 版本號可以改

Step 2:下載專案

下載本專案並移動到此資料夾底下。

git clone https://github.com/cythilya/nightwatch101.git & cd nightwatch101

Step 3:安裝相關檔案

npm install

Step 4:啟動 Nightwatch,並進行測試

npm test

測試報告

安裝 nightwatch-html-reporter

npm install -g nightwatch-html-reporter

執行指令如下,跑一次測試程式,解析 Nightwatch 所產生的 XML 檔案,最後產生客製化測試報告。

nightwatch test/e2e/
nightwatch-html-reporter -d ./reports

或者,在本專案中也可以執行:

npm run report

教學

投影片-快速上手版

Nightwatch101-手牽手一起來學 Nightwatch!

鐵人賽-詳細說明版

  1. 前言
  2. Nightwatch 與 Selenium Webdriver
  3. 環境建置
  4. 設定檔
  5. 使用 CSS Selector 定位網頁元素
  6. 使用 Xpath 定位網頁元素
  7. 指令 Part 1
  8. 指令 Part 2
  9. 指令 Part 3
  10. BDD Expect
  11. BDD Assert
  12. BDD Verify
  13. Test Hooks
  14. Asynchronous Test Hooks
  15. External Globals
  16. 簡單測試範例
  17. Nightwatch Test Runner
  18. 依照分組做測試(Test Groups)
  19. 依照標籤做測試(Test Tags)
  20. 禁跑特定測試(Disable Tests)
  21. 平行執行測試程式
  22. Page Objects
  23. 使用 Sections 優化 Page Objects
  24. 客製化指令(Custom Commands)
  25. 客製化斷言(Custom Assertions)
  26. 客製化測試報告
  27. 進階測試範例
  28. 獨立使用 ChromeDriver 跑測試
  29. Selenium IDE
  30. 總結

2018 iT 邦幫忙鐵人賽

Todos

持續改進中,未來會繼續完成的項目...

  • localhost test
  • 設定假的 https certificate,然後 bypass https
  • 假資料填充、測完後移除
  • CI/CD 整合
  • 通知機制
  • 手機版網站測試範例