When using Selenium to query the CSS properties of an element, I noticed that even though the actual background color is white, the returned value for background-color is always #000000. This issue arises in an Ionic-built app.
Upon inspecting with Chrome DevTools, I discovered that --background: #fff;
is what I actually need. However, I am unsure how to query the host property as it seems unfamiliar to me.
:host {
--background: #fff;
--color: #000;
--padding-top: 0px;
--padding-bottom: 0px;
--padding-start: 0px;
--padding-end: 0px;
--keyboard-offset: 0px;
--offset-top: 0px;
--offset-bottom: 0px;
--overflow: auto;
display: block;
position: relative;
width: 100%;
height: 100%;
font-family: var(--ion-font-family,inherit);
contain: size style;
flex: 1 1 0%;
margin: 0px !important;
padding: 0px !important;
}
The code functions correctly but does not retrieve the correct background color.
String bgColor = Color.fromString(webElement.getCssValue("background-color")).asHex();