parent-childkaratebackground-color

Can't get background color in karate


I have this code:

<div class="react-data-field separated-area case-overview-field-root important">
    <div class="row">
        <div class="col-xs-6">
               <div class="data-label">Test is important</div>
        </div>
        <div class="col-xs-6"><div class="data-value">
               <div class="easy-edit-wrapper">Click to edit</div>
        </div>
    </div>
</div>

And I am usig this code to match the backgroud-color of the row :

* match script("//div[text()='Test - is important']", "function(e){ return getComputedStyle(e)['background-color']}") == "#7d7d80"

The problem is that the background-color of the row is only in the parent div with "important" class.

How should I check the parent ?


Solution

  • Maybe try getComputedStyle(e.parentElement) ?

    As long as it is possible in JS - Karate can execute it. I'm not sure about the "important" part. You can try running JS on the console in the browser developer tools and experiment.