How can we get the font size, font color, font type used for a particular text on a web page using Selenium web driver?

+1 vote
How can we get the font size, font color, font type used for a particular text on a web page using Selenium web driver?
Jul 2, 2019 in Selenium by Deepti
3,214 views

1 answer to this question.

+1 vote

Hi Deepti, you can use getcssvalue() method to get the font size, font color, font type for a web element on a web page. Following lines of code explains how you can get these attributes using getcssvalue() method:

driver.findelement(By.Xpath("xpath_element").getcssvalue("font-size);
driver.findelement(By.Xpath("xpath_element").getcssvalue("font-colour);
driver.findelement(By.Xpath("xpath_element").getcssvalue("font-type);
driver.findelement(By.Xpath("xpath_element").getcssvalue("background-colour);   
answered Jul 2, 2019 by Abha
• 27,930 points

Related Questions In Selenium

0 votes
2 answers

How to get the text from a website using selenium?

driver.findElement(By.cssSelector("p")).getText() or  IWebElement element = Browser.GetElementByCssSelector("div.loginbox p"); string text = ...READ MORE

answered Sep 5 in Selenium by Sri
• 2,970 points
10,549 views
0 votes
1 answer

How to extract text from a web page using selenium and save it as a text file?

Hello Isha, you can checkout this code ...READ MORE

answered May 7, 2019 in Selenium by Anvi
• 14,110 points
19,683 views
0 votes
1 answer

How can I scroll a web page in Mozilla Firefox using Selenium?

Hi Rohan, steps to scroll a webpage in ...READ MORE

answered May 13, 2019 in Selenium by Pratibha
• 3,690 points
877 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
3,549 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,554 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,608 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
2,884 views
0 votes
1 answer
0 votes
1 answer

How can I locate inline elements from a web page using Selenium Webdriver?

Which specific element you are trying to ...READ MORE

answered Oct 10, 2019 in Selenium by Abha
• 27,930 points
1,713 views