import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class GetCssfontsizecolor {
public static void main(String[] a) {
// Initialize Firefox driver
WebDriver driver = new FirefoxDriver();
//Maximize browser window
driver.manage().window().maximize();
//Go to URL
driver.get("https://www.google.com/");
//Set selenium webdriver get timeout
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
String font_name, font_size, font_color;
// Get font family name
font_name = driver.findElement(By.partialLinkText("Gmail")).getCssValue("font-family").trim();
// Get font size
font_size = driver.findElement(By.partialLinkText("Gmail")).getCssValue("font-size").trim();
// Get font color
font_color = driver.findElement(By.partialLinkText("Gmail")).getCssValue("color").trim();
System.out.println("font-family : " + font_name);
System.out.println("font-size : " + font_size);
System.out.println("font-color : " + font_color);
// Browser close
driver.close();
}
}
How to get css value in selenium webdriver using java
Subscribe to:
Post Comments (Atom)
Thank You For your Awosme Tutorials On Selenium Webdriver With Java it will Most Usefull For Begginers like me and more and who are trying to learn own from Web. Once Again Thank you For Your Effort.
ReplyDelete