Thursday, 29 May 2014

Highlighting the web element using selenium webdriver.

package RandD;

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;

public class testing {

public static void main(String[] args ) throws InterruptedException {
WebDriver driver=new FirefoxDriver();

driver.manage().window().maximize();

driver.get("https://www.facebook.com/");
WebElement element= driver.findElement(By.id("email"));
element.sendKeys("ngowda");
//for (int i = 0; i < 2; i++) {

       JavascriptExecutor js = (JavascriptExecutor) driver;
       js.executeScript("arguments[0].setAttribute('style', arguments[1]);",

               element, "color: red; border: 2px solid red;");
}
}

No comments:

Post a Comment