Highlighting the elements

Hi,

I want to highlight the elements in the webpage for example if i have 3 elements on my webpage and i want to have the cursor for each element for about 10 secs is there any way to do it.

Could you be more specific - a screenshot of the web page containg the elements would help :slight_smile:

Capture

I want to highlight each element and then the test flows for other selections.Thanks for your time :slight_smile:

So i just searched for similar topics for you and this @Bob_H has done the work for you - please have a read of the following

Here is a way to do it.

  1. In Katalon, go to Keywords folder.
  2. Create a package and call it, com.reusableComponents
  3. Create a keyword and call it, HighlightElement
  4. Copy and paste this code in your keyword.
  5. In Katalon Add > Custom Keyword, Select com.reusableComponents.HighlightElement.run and in the object Column

Copy code

package com.reusableComponents

import org.openqa.selenium.JavascriptExecutor

import org.openqa.selenium.WebDriver

import org.openqa.selenium.WebElement

import org.testng.Assert

import com.kms.katalon.core.annotation.Keyword

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

import com.kms.katalon.core.webui.common.WebUiCommonHelper

import com.kms.katalon.core.webui.driver.DriverFactory

public class HighlightElement {

static WebDriver driver = DriverFactory.getWebDriver()

@Keyword

public static void run(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: 5px solid red;');",

                element);

    }

} catch (Exception e) {

    Assert.fail(e.getMessage());

}

}

}

Or have a read of this

I have read that am new to the katalon just exploring the options how can i create a package can you help me with any docs

Sure thing - have a read of this one

https://docs.katalon.com/katalon-studio/docs/introduction-to-custom-keywords.html#create-a-custom-keyword