Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98773

How to highlight elements by setting some flag

$
0
0

Below is the code I am using to highlight the element.

public static void highLightElement(WebDriver driver, WebElement element)
{
JavascriptExecutor js=(JavascriptExecutor)driver; 

js.executeScript("arguments[0].setAttribute('style', 'background: yellow; border: 2px solid red;');", element);

try 
{
Thread.sleep(1000);
} 
catch (InterruptedException e) {

System.out.println(e.getMessage());
} 

js.executeScript("arguments[0].setAttribute('style','border: solid 2px white');", element); 

}

}

Now I am calling this reusable to my code. But I want to use it in such a way that it will highlight elements only if I use some kind of flag (true). My motto is that it will not highlight element in normal execution but if I flag it I can see the highlighted element while debugging.


Viewing all articles
Browse latest Browse all 98773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>