- 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 - Selenese 命令
Selenium IDE 中使用的每個命令都稱為 Selenese 命令。使用 Selenese 命令,我們可以在 Web 應用程式上執行所有測試活動。Selenese 命令分為三種類型:
因此,Selenese 是一種用於使用 Selenium IDE 建立測試自動化的語言。我們也可以在 Selenium IDE 命令中定義 Selenese。這些 Selenese 命令可以廣泛用於測試 Web 應用程式的功能。
基本的動作命令
動作命令用於操作被測應用程式的狀態。Selenium IDE 中提供了各種型別的動作命令。
- click(定位器)
- check(定位器)
- uncheck(定位器)
- 在下一個確認對話方塊中選擇取消
- 在下一個提示框中選擇取消
- 在下一個確認對話方塊中選擇確定
- clickAt(定位器, 座標字串)
- close
- debugger
- doubleClick(定位器)
- doubleClickAt(定位器)
- dragAndDropToObject(源定位器, 目標定位器)
- echo(訊息)
- editContent(定位器, 值)
- executeScript(指令碼, 變數名)
- executeAsyncScript(指令碼, 變數名)
- mouseDown(定位器)
- mouseDownAt(定位器, 座標字串)
- mouseMoveAt(定位器, 座標字串)
- mouseOut(定位器)
- mouseOver(定位器)
- mouseUp(定位器)
- mouseUpAt(定位器, 座標字串)
- open(URL)
- pause(等待時間)
- removeSelection(定位器, 選項)
- run(測試用例)
- select(定位器, 選項)
- selectFrame(定位器)
- selectWindow(視窗控制代碼)
- setWindowSize(解析度)
- type(定位器)
基本的獲取器命令
獲取器命令用於操作被測應用程式的狀態。
以下是獲取器命令:
- store(文字, 變數)
- storeAttribute(定位器, 變數)
- storeText(定位器, 變數)
- storeTitle(文字, 變數)
- storeValue(定位器, 變數)
- storeWindowHandle(視窗控制代碼)
- storeXpathCount(xpath, 變數)
基本的斷言命令
斷言命令用於檢查被測應用程式的狀態。Selenium IDE 中提供了各種型別的斷言命令。
- assert(變數, 預期值)
- assertAlert(警報文字)
- assertChecked(定位器)
- assertConfirmation(文字)
- assertEditable(定位器)
- assertElementPresent(定位器)
- assertElementNotPresent(定位器)
- assertNotChecked(定位器)
- assertNotEditable(定位器)
- assertNotSelectedValue(定位器, 文字)
- assertNotText(定位器, 文字)
- assertPrompt(文字)
- assertSelectedValue(定位器, 文字)
- assertSelectedLabel(定位器,文字)
- assertText(定位器, 文字)
- assertTitle(文字)
- assertValue(定位器, 文字)
- verify(變數, 預期值)
- verifyChecked(定位器)
- verifyEditable(定位器)
- verifyElementPresent(定位器)
- verifyElementNotPresent(定位器)
- verifyNotEditable(定位器)
- verifyNotSelectedValue(定位器, 文字)
- verifyNotText(定位器, 文字)
- verifySelectedLabel(定位器, 文字)
- verifySelectedValue(定位器, 文字)
- verifyText(定位器, 文字)
- verifyValue(定位器, 文字)
- waitForElementEditable(定位器, 等待時間)
- waitForElementNotEditable(定位器, 等待時間)
- waitForElementNotPresent(定位器, 等待時間)
- waitForElementNotVisible(定位器, 等待時間)
- waitForElementPresent(定位器, 等待時間)
- waitForElementVisible(定位器, 等待時間)
示例
讓我們以以下頁面為例,我們將使用獲取器命令捕獲頁面標題Selenium Practice - 單選按鈕。然後使用動作命令單擊是標籤旁邊的單選按鈕。
選擇單選按鈕後,我們將獲得文字 - 您已選中是,我們將使用斷言命令驗證此文字。
以下是需要遵循的步驟:
步驟 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 - 在“命令”欄位中輸入 storeTitle,在“值”欄位中輸入 pageTitle。請注意,pageTitle 是用於捕獲已啟動頁面的標題的變數。
步驟 7 - 在“命令”欄位中輸入 echo,在“目標”欄位中輸入 ${pageTitle}。請注意,這將在 Selenium IDE 的日誌中列印我們在步驟 6 中獲得的文字。
步驟 8 - 在“命令”欄位中輸入 click,在“目標”欄位中輸入 xpath=/html/body/main/div/div/div[2]/form/div[1]/input。請注意,xpath=/html/body/main/div/div/div[2]/form/div[1]/input 是單選按鈕的定位器值。
步驟 9 - 在“命令”欄位中輸入 assertElementPresent,在“目標”欄位中輸入 xpath=//*[@id="check"]。請注意,xpath=//*[@id="check"] 是文字 - 您已選中是的定位器值。
步驟 10 - 在“命令”欄位中輸入 close 以關閉瀏覽器視窗。
步驟 11 - 點選左側窗格中顯示的三個點,然後選擇“重新命名”選項。
步驟 12 - 在“重新命名測試用例”欄位中輸入名稱,例如 Test9,然後點選“重新命名”。輸入的名稱將顯示在 Selenium IDE 的左側。
步驟 13 − 點選頂部的“執行所有測試”,然後等待測試執行完成。在我們的示例中,我們將看到“執行:1,失敗:0”,以及一個綠色條表示測試成功執行且沒有任何失敗。此外,“日誌”下方還會顯示成功完成的訊息。
在上面的示例中,我們使用 open 命令啟動了應用程式,並在“日誌”中使用 store title 命令獲得了頁面標題Selenium Practice - Radio Button。我們使用 click 命令點選了單選按鈕,並使用 assert element present 命令驗證了文字 - You have checked Yes。此外,測試用例名稱 - Test9 旁邊出現了一個綠色勾號,表示測試透過。
本教程到此結束,我們全面介紹了 Selenium IDE - Selenese 命令。我們從描述 Selenese 命令開始,介紹了各種訪問器、操作和斷言命令,並透過示例演示瞭如何將 Selenese 命令與 Selenium 一起使用。
本教程使您深入瞭解 Selenium IDE 中的 Selenese 命令。建議您繼續練習所學內容,並探索與 Selenium 相關的其他內容,以加深您的理解並拓寬視野。
