有人可以通过Groovy代码在Katalon Studio中创建自定义关键字来检查元素是否被选中或显示为灰色吗?
答案 0 :(得分:0)
下面是打开Katalon主页并检查是否已选择“免费下载”按钮的示例(使用WebElement的.selected
属性):
import org.openqa.selenium.WebElement as WebElement
import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webui.common.WebUiCommonHelper
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
WebUI.openBrowser("https://www.katalon.com")
def isSelected(TestObject to){
WebElement element = WebUiCommonHelper.findWebElement(to, 3)
return element.selected
}
TestObject tobject = new TestObject().addProperty("css", ConditionType.EQUALS, ".btn-download")
println(isSelected(tobject))