Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to get the font size of any text on webpage?

    • 0
    • 4
    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 4.60k
    Comment on it

    We use .getCssValue(attribute) method to get the properties of any webelement.

    We can pass the following attributes:

    1. font-family
    2. font-size
    3. color
    4. line-height
    WebDriver driver = new FirefoxDriver();
            driver.get("http://www.salesforce.com/");
            driver.manage().timeouts().implicitlyWait(20L, TimeUnit.SECONDS);
            driver.manage().window().maximize();
            System.out.println(driver.findElement(By.xpath(".//*[@id='qe_form_contact']/span/a[text()='Contact']")).getCssValue("font-size"));

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: