使用selenium直到在katalon工作室、Groovy中



因此,我一直在尝试实现从selenium到katalon groovy脚本的等待函数,但在下面的行中,我一直收到错误

WebUI.wait.Until(FindElement(By.XPath("//*[contains(text(), 'Fund Metrics Trend']")), 10)

如果有人能告诉我为什么会出现以下错误,这是我的代码:

原因:[0;39m[31mgroovy.lang.MissingPropertyException:没有此类属性:等待类:com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords[0];39m[31m在选项卡权限.run(选项卡权限:54([0;39m[31m在com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194([0;39m[31m,位于com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119([0;39m[31m,位于com.kms.katalon.core.main.TestCaseExecutitor.runScript(TestCaseExecutiator.java:321([0;39m[31m,位于com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutitor.java:312([0;39m[31m,位于com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:291([0;39m[31m,位于com.kms.katalon.core.main.TestCaseExecutitor.accessMainPhase(TestCaseExecutiator.java:283([0;39m[31m,位于com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:222([0;39m[31m在com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106([0;39m[31m在com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97([0;39m[31m在com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(未知来源([0;3900m[31m在TempTestCase1545063637352.run(TempTestCase15.45063637352.groovy:22([0;39m2018-12-17 11:21:19.430[1;31m错误[0;39m[36mc.k.katalon.core.main.TestCaseExecutitor-[0;39 m[31m❌测试用例/选项卡权限失败。[0;39m[31m原因:[0;39m[31mgroovy.lang.MissingPropertyException:没有此类属性:等待类:com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords[0];39m[31m在选项卡权限.run(选项卡权限:54([0;39m[31m在com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194([0;39m[31m,位于com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119([0;39m[31m,位于com.kms.katalon.core.main.TestCaseExecutitor.runScript(TestCaseExecutiator.java:321([0;39m[31m,位于com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutitor.java:312([0;39m[31m,位于com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:291([0;39m[31m,位于com.kms.katalon.core.main.TestCaseExecutitor.accessMainPhase(TestCaseExecutiator.java:283([0;39m[31m,位于com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:222([0;39m[31m在com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106([0;39m[31m在com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97([0;39m[31m在com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(未知来源([0;3900m[31m在TempTestCase1545063637352.run(TempTestCase15.45063637352.groovy:22([0;39m2018-12-17 11:21:19.430[34mINFO[0;39m[36mc.k.katalon.core.main.TestCaseExecutitor-[0;399m[39mEND测试用例/选项卡权限

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.support.ui.WebDriverWait
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
//set Web UI delay between actions to 2 seconds Project, Settings, Execution, Default, Web UI
TestData data = findTestData('Investor/Notes')
//TestData data = findTestData('temp')
WebUI.openBrowser('')
WebDriver driver = DriverFactory.getWebDriver()

WebUI.navigateToUrl(GlobalVariable.url)
WebUI.maximizeWindow()

WebDriverWait wait = new WebDriverWait(driver, long time=10)
for (def index : (0..data.getRowNumbers() - 1)) {
WebUI.setText(findTestObject('Login/Screen Elements/input_username'),               data.internallyGetValue('username', index))
WebUI.setText(findTestObject('Login/Screen Elements/input_password'), data.internallyGetValue('password', index))
WebUI.click(findTestObject('Login/Screen Elements/button_Login'))
if ((data.internallyGetValue('username', index) == 'jasmine') || (data.internallyGetValue('username', index) == 'pefadmin4') || (data.internallyGetValue('username', index) == 'pefreviewer4') || (data.internallyGetValue('username', index) == 'pefreadonly4') || (data.internallyGetValue('username', index) == 'fundaccounting4'))  {
WebUI.click(findTestObject('Client/a_DFW Capital Partners'))
WebUI.click(findTestObject('Object Repository/Fund/a_DFW Capital Partners V L.P.'))
WebUI.verifyElementPresent(findTestObject('Object Repository/Tabs Permissions/a_Dashboard'), 10)
WebUI.delay(3)
WebUI.wait.Until(FindElement(By.XPath("//*[contains(text(), 'Fund Metrics Trend']")), 10)
WebUI.delay(3)
WebUI.verifyTextPresent("Fund Metrics Trend", false)

附言:这只是我代码的上半部分,其他一切都很好。

在Katalon Studio中,您可以替换这行

WebUI.wait.Until(FindElement(By.XPath("//*[contains(text(), 'Fund Metrics Trend']")), 10)

带有以下内容(将创建测试对象,然后执行等待(:

TestObject fundMetricsTrend = new TestObject().addProperties("xpath", ConditionType.EQUALS, "//*[contains(text(), 'Fund Metrics Trend']") //this is the test object definition
WebUI.waitForElementPresent(fundMetricsTrend, 10)

注:

您需要导入这些

import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.testobject.ConditionType

此外,您还可以尝试各种WebUI.waitFor_______()函数中的任何一种,以更好地满足您的需求。

您收到错误消息,因为'wait'在WebUI类中不可用。在Katalon Studio中使用等待的一个例子是:

WebUI.waitForElementPresent(findTestObject('findTestObject('Login/Screen Elements/input_username''), 
0)

相关内容

  • 没有找到相关文章

最新更新