【Katalon學習七】Katalon web自動化測試的故障排除
阿新 • • 發佈:2019-01-02
下面的文章將幫助您在使用Katalon Studio進行web自動化測試時排除一些問題。
一、Timed out waiting for driver server to start 超時等待驅動伺服器啟動
根本原因:使用當前Edge driver不相容的問題
解決方案:
- 從這個頁面下載正確的Edge driver:https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
基於你的作業系統, - 複製下載的Edge driver,並將其替換到Katalon Studio現有的edgedriver資料夾中,例如: C:\Katalon_Studio_Windows_64-4.8\configuration\resources\drivers\edgedriver
二、Unable to record on Internet Explorer 無法在Internet Explorer中記錄
根本原因:Internet Explorer上的附加元件沒有開啟。
解決方案:
- 在Internet Explorer中開啟“管理附件”(‘Manage Add-ons’)
- 開啟RecorderExtension.RecorderBHO
三、Unable to connect to Katalon server 無法連線到Katalon伺服器
根本原因:Windows防火牆阻塞了Katalon Studio和瀏覽器驅動程式之間的連線
解決方案:您需要允許以下.exe檔案:
- geckodriver.exe
- chromedriver.exe
- iedriverserver.exe
通過Windows防火牆進行通訊。下面是訪問該介面的完整指南。
這些可執行檔案可以位於:**\\配置\\ \資源\\ \驅動程式** **\\configuration\\resources\\drivers**
在最壞的情況下,如果當前的Windows防火牆也阻止它們,您可能還需要新增谷歌Chrome (Chrome .exe)和Firefox (Firefox .exe)。
四、Use different browser versions 使用不同的瀏覽器版本
如果您希望Katalon Studio在當前安裝的版本之外使用不同的版本,有兩種方法:
- 使用自定義關鍵字 custom keywords
- 這些Firefox例項應該首先安裝在您的機器上。
建立一個自定義關鍵字(custom keywords)來開啟瀏覽器。按Ctrl + Shift + O自動匯入所需包:
package com.example import org.openqa.selenium.WebDriver import org.openqa.selenium.chrome.ChromeDriver import org.openqa.selenium.chrome.ChromeOptions import org.openqa.selenium.firefox.FirefoxDriver import com.kms.katalon.core.annotation.Keyword import com.kms.katalon.core.webui.driver.DriverFactory public class WebUICustomKeywords { @Keyword def openFirefoxBrowser(String firefoxPath, String firefoxDriver) { //Set path to Firefox version System.setProperty("webdriver.firefox.bin", firefoxPath) //Set path to Firefox driver: <Katalon Studio folder>\configuration\resources\drivers\firefox_win64\geckodriver.exe System.setProperty("webdriver.gecko.driver", firefoxDriver) WebDriver driver = new FirefoxDriver() DriverFactory.changeWebDriver(driver) } @Keyword def openChromeBrowser(String chromeDriverPath, String chromePath) { //Set path to chromedriver driver: <Katalon Studio folder>\configuration\resources\drivers\chrome_win32\chromedriver.exe System.setProperty("webdriver.chrome.driver", chromeDriverPath) ChromeOptions options = new ChromeOptions() //Set path to Chrome binary options.setBinary(chromePath) WebDriver driver = new ChromeDriver(options) DriverFactory.changeWebDriver(driver) } }
- 在測試用例中,使用自定義關鍵字(custom keyword)而不是“Open Browser”關鍵字,例如:
CustomKeywords.'com.example.WebUICustomKeywords.openFirefoxBrowser'('C:\\Program Files\\Mozilla Firefox 52\\firefox.exe', 'C:\\5.4\\Katalon Studio Windows 64\\configuration\\resources\\drivers\\firefox_win64\\geckodriver.exe') WebUI.navigateToUrl(GlobalVariable.G_SiteURL) WebUI.click(findTestObject('Page_CuraHomepage/btn_MakeAppointment'))
- 降低瀏覽器的版本:
另一種方法是將當前瀏覽器的版本降級為您想要的版本。如果您想使用舊版本的瀏覽器,您可能需要降低或升級瀏覽器的驅動程式以及Selenium WebDriver,請參閱本指南:https://docs.katalon.com/display/KD/Update+or+Replace+Web+Browser+Drivers+and+Selenium