Verifying a label and wanted to hightlight with a color

Try this:

public class Highlight {
  
  /**
   * Highlight an element for five seconds using JavaScript.
   * @param selector (String) The CSS selector for the element.
   */
  @Keyword
  public static void highlightElement(String selector) {
    // Triple-quoted string containing JavaScript
    String js = '''
      function highlightElement(selector) {
        $(selector).css("box-shadow", "1px 1px 4px 4px yellow, -1px -1px 4px 4px yellow");
        setTimeout(function() {
          $(selector).css("box-shadow", "none");
        }, 5000);
      }

      highlightElement(selector);
    '''
    // execute the JavaScript
    WebUI.executeJavaScript(js, Arrays.asList(selector))
  }
}

Notes:

  1. You don’t need to use @Keyword if you never use Manual View.
  2. I believe a method called run has special meaning in script classes - I changed it to highlightElement and named the class Highlight.
  3. This method does not need Webdriver. It uses JavaScript to directly target the element using a suitable CSS selector.
  4. Note the JavaScript is a multi-line string surrounded by triple quotes - ''' and '''

Example call:

import static package_name.Highlight.*

//highlight the element with id="username"
highlightElement("#username")