Hey Karan, you can use following code snippet to check whether a text is highlighted on a page using Selenium:
String color = driver.findElement(By.xpath("//a[text()='Shop']")).getCssValue("color");
String backcolor = driver.findElement(By.xpath("//a[text()='Shop']")).getCssValue("background-color");
System.out.println(color);
System.out.println(backcolor);
if(!color.equals(backcolor)){
System.out.println("Text is highlighted!")
}
else{
System.out.println("Text is not highlighted!")
}
Here if both color and back color different then that means that element is in different color.