I want to create 3rd party jar file for "customize wait" functionality, which will further use in Katalon studio Test Cases to synchronize the test case by calling "waitTillObjectPresent()".
Sample of my calling function from Katalon Studio would be like below:
Here I am trying to call java function "waitTillObjectPresent()" from Katalon Studio.
WebUI.navigateToUrl('https://www.companysite.com/en')
//Wait for element till present upto 10 sec.
WaitForObject.waitTillObjectPresent'(findTestObject('V3-Web/WaitForObject/Page_Livtten/button_Results'), 10)
WebUI.click(findTestObject('V3-Web/WaitForObjectDemo/Pagetten/button_Results'))
Note : In the above code "WaitForObject" is my Java Class and "waitTillObjectPresent" is fluent wait method in same class.
Tried with following java code :
public void waitTillObjectPresent(TestObject to, int waitingtime){
// HERE IS ISSUE, I am not getting TestObject from Katalon Studio calling method
int counter=0;
String locator= object.findPropertyValue('xpath');
System.out.println("xpath is:: " + locator);
WebDriver driver = DriverFactory.getWebDriver();
// HERE IS ISSUE, I am not able to getting WebDriver instance from Katalon Studio
// fluent wait method
Wait wait = new FluentWait(driver )
.withTimeout(waitingtime, TimeUnit.SECONDS)
.pollingEvery(1000, TimeUnit.MILLISECONDS)
.ignoring(WebElementNotFoundException.class)
WebElement ele = (WebElement) wait.until(new Function<WebDriver, WebElement>() {
public WebElement apply(WebDriver driver) {
counter ++
return driver.findElement(By.xpath(locator));
}
});
System.out.println("Waiting time for Object ::: "+ object+" ::: rendering is :::: " +counter*700 +" ::: miliseconds ie in seconds ::: " +(counter*700)/1000);
}
}
In the above code I am getting errors at 2 points:
1st ISSUE : I am not getting the TestObject in java program from Katalon studio.
2nd ISSUE : I am not able to get the webdriver instance with the code WebDriver driver = DriverFactory.getWebDriver();
Kindly help me I am new to Katalon studio.