How to determine colors using Selenium?

SeleniumAutomation TestingTesting Tools

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

raja
Updated on 08-Feb-2022 10:30:22

Advertisements