I have published a new versin 0.21.0 of TestClosure.
In v0.20.0, a typical TestClosure was constructed as this:
import com.kazurayam.ks.testclosure.TestClosure
import org.openqa.selenium.Dimension
import org.openqa.selenium.Point
import com.kazurayam.ks.windowlayout.BrowserWindowLayoutKeyword as BrowserWindow
new TestClosure({ Point position, Dimension dimension ->
String url = 'http://forum.katalon.com/'
WebUI.openBrowser('')
//
BrowserWindow.layout(position, dimension)
//
WebUI.navigateToUrl(url)
WebUI.comment("processing ${url}")
TestObject tObj = newTestObjectXPath("//a[contains(text(),'How To Help Us Help You')]")
WebUI.verifyElementPresent(tObj, 5)
WebUI.scrollToElement(tObj, 5)
WebUI.delay(1)
WebUI.closeBrowser()
}, [])
As you can see, this TestClosure is responsible for opening/closing browser and for positioning the browser window. The code is lengthy, therefore is error prone.
Now in v0.21.0, a typical TestClosure is constructed as this:
import com.kazurayam.ks.testclosure.TestClosure
import org.openqa.selenium.WebDriver
import com.kms.katalon.core.webui.driver.DriverFactory
TestClosure tc = new TestClosure({ WebDriver driver ->
DriverFactory.changeWebDriver(driver)
String url = 'http://forum.katalon.com/'
WebUI.navigateToUrl(url)
WebUI.comment("processing ${url}")
TestObject tObj = newTestObjectXPath("//a[contains(text(),'How To Help Us Help You')]")
WebUI.verifyElementPresent(tObj, 5)
WebUI.scrollToElement(tObj, 5)
}, [])
Now the framework com.kazurayam.ks.testclosure.TestClosureCollectionExecutor
is entirely responsible for opening/closing browser, positioning browser window. An instance of WebDriver is passed to a TestClosure as argument. A TestClosure just uses the given WebDriver instance. So the code of a TestClosure in v0.21.0 is much simpler than v0.20.0.