Actually this can not be done by using any of the WebDriver locator strategies like XPATH, CSS etc. We can only use this using Javascript.
Here is the sample code in Java:-
WebElement switchLabel = driver.findElement(By.cssSelector(“.className”));
String colorRGB = ((JavascriptExecutor)driver)
.executeScript("return window.getComputedStyle(arguments[0], ':before').
If you want to learn Selenium then you must take up the following Selenium online training. You can also read the following Selenium tutorial.
Java Video:
Selenium Video: