Posts

Showing posts from February, 2017

How to highlight an Element in Selenium WebDriver

package pkg_seleniumwebdriverbestpractices; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.interactions.internal.Coordinates; import org.openqa.selenium.internal.Locatable; public class ScrollToElement { public static WebDriver driver; /** * @param args * @throws InterruptedException */ public static void highLightElement(WebElement element){ JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("arguments[0].setAttribute('style','background: yellow; border: 2px solid red;');", element); } public static void main(String[] args) throws InterruptedException { // TODO Auto-generated method stub System.setProperty("webdriver.chrome.driver", "C:...