Script to highlight element border
Script1:-
package selenium_examples;
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 Sample {
public static void main(String[] args)
{
WebDriver driver = new FirefoxDriver();
driver.get("http://www.seleniumhq.org/");
driver.manage().window().maximize();
WebElement element = driver.findElement(By.name("q"));
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].style.border='5px solid blue'", element);
}
}
Above script highlights search textbox border in www.seleniumhq.org website.
Script2:-
package selenium_examples;
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 Sample {
public static void main(String[] args)
{
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.co.in/");
driver.manage().window().maximize();
WebElement element = driver.findElement(By.name("btnK"));
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].style.border='5px solid red'", element);
}
}
Script1:-
package selenium_examples;
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 Sample {
public static void main(String[] args)
{
WebDriver driver = new FirefoxDriver();
driver.get("http://www.seleniumhq.org/");
driver.manage().window().maximize();
WebElement element = driver.findElement(By.name("q"));
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].style.border='5px solid blue'", element);
}
}
Above script highlights search textbox border in www.seleniumhq.org website.
Script2:-
package selenium_examples;
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 Sample {
public static void main(String[] args)
{
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.co.in/");
driver.manage().window().maximize();
WebElement element = driver.findElement(By.name("btnK"));
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].style.border='5px solid red'", element);
}
}
No comments:
Post a Comment