
- Selenium 教程
- Selenium - 首頁
- Selenium - 概述
- Selenium - 元件
- Selenium - 自動化測試
- Selenium - 環境設定
- Selenium - 遠端控制
- Selenium IDE 教程
- Selenium - IDE 簡介
- Selenium - 特性
- Selenium - 限制
- Selenium - 安裝
- Selenium - 建立測試
- Selenium - 建立指令碼
- Selenium - 控制流
- Selenium - 儲存變數
- Selenium - 警報和彈出視窗
- Selenium - Selenese 命令
- Selenium - 操作命令
- Selenium - 訪問器命令
- Selenium - 斷言命令
- Selenium - Assert/Verify 方法
- Selenium - 定位策略
- Selenium - 指令碼除錯
- Selenium - 驗證點
- Selenium - 模式匹配
- Selenium - JSON 資料檔案
- Selenium - 瀏覽器執行
- Selenium - 使用者擴充套件
- Selenium - 程式碼匯出
- Selenium - 程式碼輸出
- Selenium - JavaScript 函式
- Selenium - 外掛
- Selenium WebDriver 教程
- Selenium - 簡介
- Selenium WebDriver vs RC
- Selenium - 安裝
- Selenium - 第一個測試指令碼
- Selenium - 驅動程式會話
- Selenium - 瀏覽器選項
- Selenium - Chrome 選項
- Selenium - Edge 選項
- Selenium - Firefox 選項
- Selenium - Safari 選項
- Selenium - 雙擊
- Selenium - 右鍵單擊
- Python 中的 HTML 報告
- 處理編輯框
- Selenium - 單個元素
- Selenium - 多個元素
- Selenium Web 元素
- Selenium - 檔案上傳
- Selenium - 定位器策略
- Selenium - 相對定位器
- Selenium - 查詢器
- Selenium - 查詢所有連結
- Selenium - 使用者互動
- Selenium - WebElement 命令
- Selenium - 瀏覽器互動
- Selenium - 瀏覽器命令
- Selenium - 瀏覽器導航
- Selenium - 警報和彈出視窗
- Selenium - 處理表單
- Selenium - 視窗和標籤頁
- Selenium - 處理連結
- Selenium - 輸入框
- Selenium - 單選按鈕
- Selenium - 複選框
- Selenium - 下拉框
- Selenium - 處理 IFrame
- Selenium - 處理 Cookie
- Selenium - 日期時間選擇器
- Selenium - 動態 Web 表格
- Selenium - Actions 類
- Selenium - Action 類
- Selenium - 鍵盤事件
- Selenium - 鍵向上/向下
- Selenium - 複製和貼上
- Selenium - 處理特殊鍵
- Selenium - 滑鼠事件
- Selenium - 拖放
- Selenium - 筆事件
- Selenium - 滾動操作
- Selenium - 等待策略
- Selenium - 顯式/隱式等待
- Selenium - 支援功能
- Selenium - 多選
- Selenium - 等待支援
- Selenium - 選擇支援
- Selenium - 顏色支援
- Selenium - ThreadGuard
- Selenium - 錯誤和日誌記錄
- Selenium - 異常處理
- Selenium - 其他
- Selenium - 處理 Ajax 呼叫
- Selenium - JSON 資料檔案
- Selenium - CSV 資料檔案
- Selenium - Excel 資料檔案
- Selenium - 跨瀏覽器測試
- Selenium - 多瀏覽器測試
- Selenium - 多視窗測試
- Selenium - JavaScript 執行器
- Selenium - 無頭執行
- Selenium - 捕獲螢幕截圖
- Selenium - 捕獲影片
- Selenium - 頁面物件模型
- Selenium - 頁面工廠
- Selenium - 錄製和回放
- Selenium - 框架
- Selenium - 瀏覽上下文
- Selenium - DevTools
- Selenium Grid 教程
- Selenium - 概述
- Selenium - 架構
- Selenium - 元件
- Selenium - 配置
- Selenium - 建立測試指令碼
- Selenium - 測試執行
- Selenium - 端點
- Selenium - 自定義節點
- Selenium 報告工具
- Selenium - 報告工具
- Selenium - TestNG
- Selenium - JUnit
- Selenium - Allure
- Selenium 和其他技術
- Selenium - Java 教程
- Selenium - Python 教程
- Selenium - C# 教程
- Selenium - Javascript 教程
- Selenium - Kotlin 教程
- Selenium - Ruby 教程
- Selenium - Maven 和 Jenkins
- Selenium - 資料庫測試
- Selenium - LogExpert 日誌記錄
- Selenium - Log4j 日誌記錄
- Selenium - Robot Framework
- Selenium - AutoIT
- Selenium - Flash 測試
- Selenium - Apache Ant
- Selenium - Github 教程
- Selenium - SoapUI
- Selenium - Cucumber
- Selenium - IntelliJ
- Selenium - XPath
- Selenium 其他概念
- Selenium - IE 驅動程式
- Selenium - 自動化框架
- Selenium - 關鍵字驅動框架
- Selenium - 資料驅動框架
- Selenium - 混合驅動框架
- Selenium - SSL 證書錯誤
- Selenium - 替代方案
- Selenium 有用資源
- Selenium - 問答
- Selenium - 快速指南
- Selenium - 有用資源
- Selenium - 自動化實踐
- Selenium - 討論
Selenium IDE - 驗證點
Selenium IDE 允許在測試用例中新增多個驗證點,以檢查應用程式是否按預期工作。Selenium IDE 中使用的每個命令都稱為 Selenese 命令。使用 Selenese 命令,我們在 Selenium IDE 中對 Web 應用程式執行所有測試活動。
Selenese 命令由三種類型組成 - 操作、斷言和訪問器。斷言命令有助於在 Selenium IDE 測試中新增驗證點。斷言命令用於檢查被測應用程式的狀態。它有三種子型別,即 assert、verify 和 waitfor。
如何在錄製時插入驗證點?
驗證點可以在 Selenium IDE 中錄製測試時新增到測試中。在下圖中,我們添加了驗證點 - assert,方法是右鍵單擊名稱:標籤旁邊的輸入框。然後,我們選擇了Selenium IDE選項,最後,我們必須選擇Assert選項。這樣做,所有可用的 assert 命令都將準備好進行選擇。

在下圖中,我們添加了驗證點 verify,方法是右鍵單擊名稱:標籤旁邊的輸入框。然後,我們選擇了Selenium IDE選項,最後,我們必須選擇Verify選項。這樣做,所有可用的 verify 命令都將準備好進行選擇。

在下圖中,我們添加了驗證點 wait for,方法是右鍵單擊名稱:標籤旁邊的輸入框。然後,我們選擇了Selenium IDE選項,最後,我們必須選擇Wait For選項。這樣做,所有可用的 wait for 命令都將準備好進行選擇。

要詳細瞭解如何設定 Selenium IDE,請參閱以下連結:Selenium IDE 安裝。
Selenium IDE 中的基本驗證命令
以下是 Selenium IDE 中可用的各種型別的驗證命令:
- assert(variable, expected value)
- assert alert(alert text)
- assert checked(locator)
- assert confirmation(text)
- assert editable(locator)
- assert element present(locator)
- assert element not present(locator)
- assert not checked(locator)
- assert not editable(locator)
- assert not selected value(locator, text)
- assert not text(locator, text)
- assert prompt(text)
- assert selected value(locator, text)
- assert selected label(locator, text)
- assert text(locator, text)
- assert title(text)
- assert value(locator, text)
- verify(variable, expected value)
- verify checked(locator)
- verify editable(locator)
- verify element present(locator)
- verify element not present(locator)
- verify not editable(locator)
- verify not selected value(locator, text)
- verify not text(locator, text)
- verify selected label(locator, text)
- verify selected value(locator, text)
- verify text(locator, text)
- verify value(locator, text)
- wait for element editable(locator, wait time)
- wait for element not editable(locator, wait time)
- wait for element not present(locator, wait time)
- wait for element not visible(locator, wait time)
- wait for element present(locator, wait time)
- wait for element visible(locator, wait time)
示例
讓我們以以下頁面為例,在這裡我們將點選已建立連結。

我們將驗證其頁面標題,即Selenium 實踐 - 連結。點選“已建立”連結後,我們還將驗證文字 - 連結已響應狀態 201 和狀態文字已建立。

以下是需要遵循的步驟:
步驟 1 - 點選安裝後在瀏覽器上可見的 Selenium IDE 擴充套件。
步驟 2 - Selenium IDE 應隨之啟動,並顯示歡迎訊息以及工具的版本。在下圖中,安裝的版本為 3.17.2。
此外,它還為我們提供了選擇要使用工具執行的操作的選項,例如在新專案中錄製新測試、開啟現有專案、建立新專案和關閉 Selenium IDE。
此外,還提供了一個帶有文字 - Selenium IDE 專案頁面的連結,點選該連結將帶我們到 Selenium 整合開發環境文件頁面。
https://www.selenium.dev/selenium-ide/.
步驟 3 - 點選“建立新專案”連結,然後在“請為您的新專案提供名稱”下輸入專案名稱,例如 Test8。最後,我們將點選“確定”按鈕。
步驟 4 - 我們現在將在 Selenium IDE 中準備好工作區。
步驟 5 - 在“命令”欄位中輸入 open,在“目標”欄位中輸入Selenium 自動化實踐表單,以啟動應用程式。
步驟 6 - 在“命令”欄位中輸入 verify title,在“目標”欄位中輸入 Selenium Practice - Links。
步驟 7 - 在“命令”欄位中輸入 click,在“目標”欄位中輸入 xpath=//*[@id="created"]。請注意,xpath=//*[@id="created"] 是連結的定位器值。
步驟 8 - 在“命令”欄位中輸入 wait for element visible,在“目標”欄位中輸入 xpath=/html/body/main/div/div/div[2]/div[1],在“值”欄位中輸入 30000。請注意,xpath=/html/body/main/div/div/div[2]/div[1] 是要顯示的文字的定位器值。
步驟 9 - 在“命令”欄位中輸入 assert text,在“目標”欄位中輸入 xpath=/html/body/main/div/div/div[2]/div[1],在“值”欄位中輸入 Link has responded with status 201 and status text Created。請注意,xpath=/html/body/main/div/div/div[2]/div[1] 是文字的定位器值。
步驟 10 − 在命令欄位中輸入 close 以關閉瀏覽器視窗。

步驟 11 − 點選左側窗格中出現的三個點,然後選擇“重新命名”選項。
步驟 12 − 輸入一個名稱,例如在“重新命名測試用例”欄位下輸入 Test8,然後點選“重新命名”。輸入的名稱將顯示在 Selenium IDE 的左側。
步驟 13 − 點選頂部的“執行所有測試”,並等待測試執行完成。在我們的示例中,我們將看到“執行:1”、“失敗:0”,以及一個綠色條表示測試成功執行且沒有任何失敗。此外,“已成功完成”的訊息也會出現在日誌下方。

在上面的示例中,我們啟動了應用程式並使用斷言命令 verify title 驗證了其頁面標題 - Selenium Practice - Links。然後點選了 Created link,並等待文字 Link has responded with status 201 and status text Created 使用斷言命令 wait for element visible 可見,並使用另一個斷言命令 assert text 驗證了該文字。
除此之外,所有測試步驟以及測試用例名稱都變成了綠色,反映了所有步驟都透過。所有在“日誌”選項卡下顯示的步驟都顯示為綠色的“OK”。
這總結了我們關於 Selenium IDE 驗證點的教程的全面內容。我們從描述什麼是驗證點、如何插入驗證點、基本的驗證命令以及一個示例來逐步演示如何將驗證命令與 Selenium 一起使用開始。
這使您對 Selenium IDE 中的驗證點有了深入的瞭解。明智的做法是不斷練習您所學到的知識,並探索與 Selenium 相關的其他知識,以加深您的理解並拓寬您的視野。