Thursday 6 June 2013

Highlight objects in selenium WebDriver...

package abc;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
@Test
public class Highlight {
    public static void qualitree(){
        WebDriver driver = new FirefoxDriver();
        driver.get("https://www.google.co.in/");
        driver.manage().window().maximize();
        WebElement elem = driver.findElement(By.xpath(".//*[@id='gbqfba']"));
        // draw a border around the found element
        if (driver instanceof JavascriptExecutor) {
            ((JavascriptExecutor)driver).executeScript("arguments[0].style.border='3px solid red'", elem);
          
        }
      return;
    }

}

No comments:

Post a Comment