执行Selenium显式等待时Katalon中的GroovyCastException
我试图在Katalon(使用Groovy)中执行显式等待。我有以下代码:执行Selenium显式等待时Katalon中的GroovyCastException,selenium,selenium-webdriver,groovy,katalon-studio,webdriverwait,Selenium,Selenium Webdriver,Groovy,Katalon Studio,Webdriverwait,我试图在Katalon(使用Groovy)中执行显式等待。我有以下代码: // wait on page change to "Dashboard" WebDriverWait dashboardChangeWait = new WebDriverWait(driver, 3) /* This is causing the following Exception : * - GroovyCastException : Attempt to cast 'true'
// wait on page change to "Dashboard"
WebDriverWait dashboardChangeWait = new WebDriverWait(driver, 3)
/* This is causing the following Exception :
* - GroovyCastException : Attempt to cast 'true' with class 'java.lang.Boolean' to class
* 'org.openqa.selenium.WebElement'
* */
WebElement element = dashboardChangeWait.until(
ExpectedConditions.textToBe(By.cssSelector('.breadcrumb-item.active'), "DASHBOARD"))
这给了我一个
GroovyCastException
。我知道WebDriverWait.until
接受函数
(耶,类似JavaScript的编码!)参数,并且ExpectedConditions.textToBe
和until
的签名是V org.openqa.selenium.support.ui.FluentWait.until(函数arg0)
。有没有一种方法可以在Katalon中执行这种类型的等待,从而避免这个问题?您已经非常接近了。ExpectedConditions方法定义如下:
public static ExpectedCondition<java.lang.Boolean> textToBe(By locator, java.lang.String value)
An expectation for checking WebElement with given locator has specific text
Parameters:
locator - used to find the element
value - used as expected text
Returns:
Boolean true when element has text value equal to @value
Boolean status = dashboardChangeWait.until(ExpectedConditions.textToBe(By.cssSelector('.breadcrumb-item.active'), "DASHBOARD"))
/*Katalon的
WebUI
包含各种等待方法,但没有一种等待元素包含特定文本*/