Uncle Sam
Uncle Sam

Reputation: 255

How can we fetch multiple data stored in <div> table in karate?

I am trying to fetch set of data from a web table, stored/made using the <div> tags, not like the traditional html data tables. For example:

    <div class="tabulator-cell" role="gridcell" tabulator-field="program_name" title="" style="width: 135px; text-align: left; height: 30px;">
        <span style="color: #00def; font-weight: 500;">Consumer xyz</span>
    </div>
    <div class="tabulator-cell" role="gridcell" tabulator-field="business_val" title="" style="width: 119px; text-align: center; height: 00px;">
        11898
        <div class="tabulator-col-resize-handle"></div>
        <div class="tabulator-col-resize-handle prev"></div>
    </div>

So, I am using scriptAll() method for this and need data just for 'Consumer xyz' here but unable to do so.

    * def list = scriptAll('div div', '_.textContent', function(x){ return x.contains('Consumer xyz') })
    * delay(3000)
    * print list 

Any help on this would be appreciated. Thanks in advance.

Upvotes: 1

Views: 938

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58088

I'll just give you one hint. This is how you can get a reference to the parent div of the row:

* def temp = locate('{}Consumer Banking').parent.parent

Now it is up to you:

* def businessValue = temp.locate("[tabulator-field='business_value']")
* match businessValue.text.trim() == '11898'

Upvotes: 1

Related Questions