I want to get the style value from an element and assign it to a string var. I tried using the below code but it returns a value of 'rgb(173, 255, 47)' when I'm trying to return the value 'background:#ADFF2F"':
IWebElement highlightedText = _driver.FindElement(By.Id("firstHeading")).FindElement(By.CssSelector("th-highlight-span"));
actualHighlightColour = highlightedText.GetAttribute("style");
This is the src code from the web page I want to get the value of style from:
<h1 id="firstHeading" class="firstHeading" lang="en">
::before
<th-highlight-span style="background:#ADFF2F" data-
rwstate="ss">California Proposition 218 (1996)</th-highlight-span>
The code I tried to use returns 'rgb(173, 255, 47)' which can be found here but I want to return background: #ADFF2F:
element.style {
background: #ADFF2F;
background-image: initial;
background-position-x: initial;
background-position-y: initial;
background-size: initial;
background-repeat-x: initial;
background-repeat-y: initial;
background-attachment: initial;
background-origin: initial;
background-clip: initial;
background-color: rgb(173, 255, 47);