We can use highlight element for debugging, since in some cases due to mismatch from locators selenium will identify different element while execution, highlighting element will useful to identify the element for action during the execution so that we can modify the element if it is different element. highlight element can be done as follows:
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get(“https://yahoo.com”);
// Locate the web element
WebElement elem = driver.findElement(By.id(“sendBtn”));
// Cast driver to JavascriptExecutor
JavascriptExecutor js = (JavascriptExecutor) driver;
// Highlight the element with a red border
js.executeScript( “arguments[0].style.border=’3px solid blue'”, elem );
sukanya meruva Answered question