Wednesday, February 7, 2018

How to highlight the WebElement using selenium WebDriver

You want to highlight an element/object in webpage using the selenium webdriver. add the below code in your function to highlight the web element

WebElement we = driver.findElement(By.xpath("//div[@name='firstempty']/b"));
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("arguments[0].style.border='3px solid red'", we);

The above code can be used for any web element provided available in the web page and able to identify using the given locator

No comments:

Post a Comment