Skip to content
Advertisement

How to get text color using Selenium Python

My goal is to get the color of the text from each cell in 1 column table. The HTML for a single cell looks like this:

JavaScript

My code to find the text color of each column looks like this:

JavaScript

The loop does check the correct cell in each iteration, but the color is always “rgba(0, 0, 0, 1)” which is wrong because the text color changes and is never black. I tried replacing color with background-color, which returned the correct background color for each cell. Unfortunately, I need the text color. Replacing color with font-color or text-color doesn’t work either.

Advertisement

Answer

Change this :

JavaScript

to :

JavaScript

and get the color like this :

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement