我无法单击对象/无法使用xpath在登录框中设置文本
WebUI.setText(driver.findElement(By.xpath("//*[@id=\"edit-name\"]")), username)
WebUI.setText(driver.findElement(By.xpath("//*[@id=\"edit-pass\"]")), password)
WebUI.click(driver.findElement(By.xpath("//*[@id=\"user-login\"]/div/div/button")))文本应输入到登录框中,单击Go按钮!
发布于 2019-01-02 14:52:12
WebUI object适用于TestObject,而不是selenium的WebElement。您可以使用手动模式或脚本模式来创建测试脚本。
发布于 2019-01-02 15:26:14
首先,像这样定义测试对象:
TestObject editName = new TestObject().addProperty('xpath', ConditionType.EQUALS, '//[@id=\"edit-name\"]')
TestObject editPass = new TestObject().addProperty('xpath', ConditionType.EQUALS, '//[@id=\"edit-pass\"]')
TestObject userLogin = new TestObject().addProperty('xpath', ConditionType.EQUALS, '//*[@id=\"user-login\"]/div/div/button')然后在脚本中使用它们
WebUI.setText(editName, username)
WebUI.setText(editPass, password)
WebUI.click(userLogin)注意:我猜这里使用的用户名和密码是变量名,否则使用' username‘和' password’。
注意2:脚本的顶部需要以下导入:
import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.TestObject as TestObject发布于 2019-01-02 14:21:04
请不使用对象WebUI进行尝试。如果你能在控制台中分享完整的代码和错误信息,那就太好了。
https://stackoverflow.com/questions/54001962
复制相似问题