Search code examples
seleniumrobotframework

Element's background color in selenium/robotframework


Is there a way to get the background color of an the element in selenium robotframework? I'm trying with get attribute but it won't work and returns None

here is the html

<li pl-repeat="(slideId, slideContents) in slides" pl-click="viewSlide(slideContents['w-l'].url, slideId)" pl-class="{checked : slideId == viewSlideKey}" class="pl-scope checked"><span class="pl-binding">Draft</span></li>

Solution

  • you can do it using javascript return document.defaultView.getComputedStyle(document.getElementByID("ID"),null)['background-color']

    if it's a class then same thing but document.getElementsByClassName("class-name")[0],null)['background-color']