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, 2019 in Selenium by Deepti
707 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, 2019 by Abha
• 27,760 points

Related Questions In Selenium

0 votes
1 answer
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
3,366 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,010 points
7,338 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
404 views
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,510 points
1,570 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,870 points
1,501 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,870 points
1,284 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,760 points
989 views