WebdriverIO - 順利執行流程



讓我們建立一個簡單的順利執行流程來演示如何建立一個基本的 WebdriverIO 測試:

步驟 1 - 安裝 NodeJS。如何在執行此安裝的詳細資訊在標題為“NodeJS 入門”的章節中詳細介紹。

步驟 2 - 安裝 NPM。如何在執行此安裝的詳細資訊在標題為“NPM 安裝”的章節中詳細介紹。

步驟 3 - 安裝 VS Code。如何在執行此安裝的詳細資訊在標題為“VS Code 安裝”的章節中詳細介紹。

步驟 4 - 建立配置檔案。如何在執行此安裝的詳細資訊在標題為“配置檔案生成”的章節中詳細介紹。

步驟 5 - 建立一個規範檔案。如何在執行此安裝的詳細資訊在標題為“Mocha 安裝”的章節中詳細介紹。

步驟 6 - 在建立的 Mocha 規範檔案中新增以下程式碼。

// test suite name
describe('Tutorialspoint application', function(){
   //test case
   it('Happy Flow', function(){    
      // launch url
      browser.url('https://tutorialspoint.tw/about/about_careers.htm')
      //identify element with link text then click
      $("=Team").click()
      //verify URL of next page with assertion
      expect(browser).toHaveUrlContaining('team')
   });
});

步驟 7 - 使用以下命令執行配置檔案 - wdio.conf.js 檔案:

npx wdio run wdio.conf.js

如何在建立配置檔案的詳細資訊在標題為“wdio.conf.js 檔案”和標題為“配置檔案生成”的章節中詳細討論。

您的計算機上將出現以下螢幕:

Happy Path

步驟 8 - 進一步調查輸出後,我們將看到規範檔案 testcase1.js 中的測試標記為 PASSED。

測試執行的瀏覽器版本和作業系統、會話 ID、規範檔案名、測試套件名稱 - Tutorialspoint 應用程式、測試用例名稱 - 順利執行流程、測試執行持續時間等,也已記錄在控制檯中。

廣告
© . All rights reserved.