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.
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.