I have created a keyword to highlight testobject. Please tell me how to call this keyword globally in such a way that it should highlight testobject of each step during test case execution
public class HighlightElement {
static WebDriver driver = DriverFactory.getWebDriver()
@Keyword
public static void HighlightObject(TestObject objectto) {
try {
WebElement element = WebUiCommonHelper.findWebElement(objectto, 20);
for (int i = 0; i < 5; i++) {
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].setAttribute('style','background: yellow; border: 2px solid red;');",
element);
}
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
Yes, actually there is. But it’s beyond my time available to describe here (and honestly, I’d probably mess it up). It involves some deep(er) understanding of Groovy metaprogramming functionality.
Read up on InvokeMethod, if you really want to do this.
I have learned how to apply Groovy’s meta-programming technique to Katalon Studio. Now I can make patches to Katalon Studio runtime. I can try anything without waiting for Katalon Team to change the original source and release a new version. See How to write Katalon Studio tests with IntelliJ IDEA and other IDEs
So I would like to say:
I support the idea of making Katalon Studio to be more open sourced
Choosing Groovy language, rather than Java, for Katalon Studio was a good design decision.
Well, I think that the feature of highlighting HTML elements is useful for making the videos for tutorials. Also for lightning talks and presentations at meet-up events for audiences.
That’s exactly what I use it for. In another app I work on, I use it when I’ve turned on a debugging layer so that targeted elements have various outlines (colors) left behind like a “trail” of where the code has been.