1

I have this code :

   `<div class="form-group">
       <div class="col-md-3">
         <label class="control-label" for="fieldIsReadonly">Is Read Only?</label>
      </div>
      <div class="col-md-9 field-properties">
          <input id="fieldIsReadonly" type="checkbox" class="checkbox" value="true" aria-   invalid="false">`your text`
      </div>
    </div>`

I want search for #fieldIsReadonly and check if parent div has class "form-group". Is this posible in karate ?

2 Answers2

1

In karate you can do something like this

waitFor("//tr[td[text()='...']]//a[@class='...']").click()

This will click the element you want

Fedor
  • 17,146
  • 13
  • 40
  • 131
morfaji28
  • 26
  • 5
0

Isn't that straightforward using CSS selctors:

* locate(".form-group label[for='fieldIsReadonly']")

Else refer this for other ideas:

https://stackoverflow.com/a/65590055/143475 | https://stackoverflow.com/a/66900081/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • so i have this checkbox and the only thing that is changing when pressed is this line :
    – Andrei Vartic Aug 02 '23 at 08:26
  • @AndreiVartic yes one of the links above talks about "tree walking": https://github.com/karatelabs/karate/tree/master/karate-core#tree-walking - that should give you a solution – Peter Thomas Aug 02 '23 at 10:48
  • This was the code in cypress : cy.contains("#table" + "td", "customer name").parent("tr").children('td').find("#edit").click() . Do you have something like this in karate ? – Andrei Vartic Aug 04 '23 at 10:32
  • @AndreiVartic all that and more is possible in karate, but I can't help you more than this. please can you try read the links to other examples and try – Peter Thomas Aug 04 '23 at 11:08
  • it is posible, but how ? for 2 week I am searching for options to do this. I read all of your documentation, exemples, nothing helped. – Andrei Vartic Aug 07 '23 at 09:34
  • @AndreiVartic then please provide a live example. see how another team provided this (see comments): https://stackoverflow.com/q/76680593/143475 – Peter Thomas Aug 07 '23 at 10:15