Syntax error How to determine colors using Selenium?

How to determine colors using Selenium?



Selenium has the color conversion support class. We have to add the statement from selenium.webdriver.support.color import Color to convert colors to rgba/hex format.

Example

from selenium import webdriver
from selenium.webdriver.support.color import Color

#color conversion to rgba format
print(Color.from_string('#00fe37').rgba)

#color conversion to hex format
print(Color.from_string('rgb(1, 200, 5)').hex)

#color conversion to rgba format
print(Color.from_string('green').rgba)

Output

Updated on: 2022-02-08T10:30:22+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements