Can someone please help!
How can I highlight all web elements in following class during test execution in WebDriver? With Selenium RC, it was quite straight forward
Here the code for higlighting the element in selenium: First create a class:
package com.demo.misc.function;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class Miscellaneous
{
public static void highLight(WebElement element, WebDriver driver)
{
for (int i = 0; i <2; i++)
{
try {
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].setAttribute('style', arguments[1]);", element, "color: black; border: 4px solid red;");
Thread.sleep(500);
js.executeScript("arguments[0].setAttribute('style', arguments[1]);", element, "");
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
And then you can call this by :
driver.get(baseUrl);
Thread.sleep(2000);
WebElement lnkREGISTER = driver.findElement(By.linkText("REGISTER"));
Miscellaneous.highLight(lnkREGISTER, driver);
lnkREGISTER.click();