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

0 votes
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 in Selenium by Deepti
249 views

1 answer to this question.

0 votes

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 by Abha
• 27,180 points

Related Questions In Selenium

0 votes
1 answer

How to get the text from a website using selenium?

hey, you can use get.text() method to ...READ MORE

answered Dec 31, 2018 in Selenium by Sudhanshu
1,809 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

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,110 points
926 views
0 votes
1 answer
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,130 points
1,108 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
845 views
0 votes
1 answer
0 votes
1 answer