跨瀏覽器測試(手動設定WebDriver)
您可將Recorder錄製出的測試案例於多種瀏覽器上運行,包含桌面瀏覽器Chrome、Firefox、Edge、Safari,與Android上之瀏覽器。本文將介紹如何在同一台電腦上達成跨瀏覽器測試。
桌面瀏覽器
- 安裝Java SE
- 建立一個目錄,例如
selenium_server
- 下載Selenium Server (建議版本:4.8.0)
- 將
selenium-server-{version}.jar
存放至selenium_server
目錄
- 下載瀏覽器Web Driver並存放至
selenium_server
目錄
下列為目前Rapi支援的瀏覽器
Chrome
- 下載chromeDriver,請選擇符合電腦上瀏覽器版本
- 解壓縮後存放至
selenium_server
目錄
Firefox
- 下載geckodriver,請選擇符合電腦上作業系統版本
- 解壓縮後存放至
selenium_server
目錄
Edge
- 下載msedgedriver,請選擇符合電腦上瀏覽器版本
- 解壓縮後存放至
selenium_server
目錄
Safari
- 開啟命令列並執行
safaridriver --enable
,輸入您的使用者密碼
- 開啟Safari,點選Safari > Preferences > Advanced以啟用Develop選單,勾選Show Develop Menu
- 點選Develop選單->Allow Remote Automation以啟用Remote Automation,.
- 開啟Recorder並點選右上方設定按鈕
- 啟用 Playback through WebDriver
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- 在WebDriver Settings中之Server URL欄位填入
localhost
,在Port欄位填入4444
- 在browerName欄位填入
chrome
、firefox
、MicrosoftEdge
或safari
,並在其他欄位留白
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- 開啟命令列並將路徑變更為
selenium_server
目錄,執行java -jar selenium-server-{version}.jar standalone
- 如果您使用的是 MAC 作業系統,請在selenium_server目錄下於命令列輸入以下指令來授予瀏覽器WebDriver權限:
- 針對Chrome瀏覽器,請執行
spctl --add --label 'Approved' chromedriver
- 針對Firefox瀏覽器,請執行
spctl --add --label 'Approved' geckodriver
- 針對Edge瀏覽器,請執行
spctl --add --label 'Approved' MicrosoftWebDriver
- 針對Safari瀏覽器則無需做任何動作
- 播放測試案例。這些被設定的瀏覽器將會被Selenium Server所啟動並運行測試案例。
行動瀏覽器
底下為目前Rapi所支援的行動裝置平台
Android(Emulator)
第1到7步驟為建置Appium與Android Emulator,如果已有Appium與Android環境可跳到第8步驟
- 安裝 Appium
- 安裝 Java
- 下載 Android Studio,確認有裝 Android SDK Tools
(Customize→All settings →Appearance&Behavior→System Settings→Android SDK→SDK Tools)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- 使用Android Studio的 Android Virtual Device 功能來啟動一個虛擬機,並確認開啟
USB debugging
功能
- 下載 Chromedriver,請選擇符合行動裝置上瀏覽器版本
- 開啟Appium並點選
Edit Configurations
,於ANDROID_HOME
輸入Android Studio的SDK Location,於JAVE_HOME
輸入/path/to/JAVA/jrex.x.x_x
。點選Save and Restart
- Appium切換至
Advanced
設定,捲動至Android
並於Chromedriver Binary Path
填入Chrome Driver檔案路徑,點選Start Server
- 開啟Rapi設定頁面,
WebDriver Settings
->Add New Service
->Appium
,Server URL
填入localhost
,Port
填入4723
。點選Add New Browser
,於browserName、platfromName、deviceName、automationName欄位分別填入chrome
、android
、<YOUR_PHONE_NAME>
、UiAutomator2
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- 於
Basic Setting
中啟用Playback through WebDriver
- 播放測試案例
iOS(Simulator)
- 啟動iOS Simulator
- Appium切換至
Advanced
設定,捲動至iOS
並於WebDriverAgent Port
輸入8100
,點選Start Server
- 開啟Rapi設定頁面,
WebDriver Settings
->Add New Service
->Appium
,Server URL
填入localhost
,Port
填入4723
。點選Add New Browser
,於browserName、platfromName、deviceName、automationName欄位分別填入Safari
、iOS
、<YOUR_PHONE_NAME>
、XCUITest
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- 於
Basic Setting
中啟用Playback through WebDriver
- 播放測試案例