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
15,899 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 3, 2019 by Abha
• 28,140 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 6, 2020 in Selenium by Sri
• 3,190 points
25,076 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,150 points
33,104 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 14, 2019 in Selenium by Pratibha
• 3,690 points
2,861 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,500 points
12,619 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

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

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
8,572 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,910 points
6,629 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 3, 2020 in Selenium by Sri
• 3,190 points
7,519 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
• 28,140 points
3,715 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP