Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140762

Using Cypress - how to find adjacent items in a certain state

$
0
0

I have a long table with status buttons:

enter image description here

<td class="evaluation-button-cell">
  <button class="conduct btn btn-tertiary">Met</button>
  <button class="conduct btn btn-tertiary">Not Met</button>
</td>
<td class="evaluation-button-cell">
  <button class="conduct btn btn-tertiary">Met</button>
  <button class="conduct btn btn-tertiary">Not Met</button>
  <button class="conduct btn btn-warning">N/A</button>
</td>
<td class="evaluation-button-cell">
  <button class="conduct btn btn-tertiary">Met</button>
  <button class="conduct btn btn-danger">Not Met</button>
  <button class="conduct btn btn-tertiary">N/A</button>
</td>
<td class="evaluation-button-cell">
  <button class="conduct btn btn-success">Met</button>
  <button class="conduct btn btn-tertiary">Not Met</button>
  <button class="conduct btn btn-tertiary">N/A</button>
</td>
<td class="evaluation-button-cell">
  <button class="conduct btn btn-tertiary">Met</button>
  <button class="conduct btn btn-danger">Not Met</button>
</td>

I need to find a Not Met button with class btn-danger, which also has an adjacent N/A button (with class btn-teriary) and click the N/A button.

I'm a bit lost in all the Cypress options of get, find, within, etc.

I can find one of the buttons but not sure the best approach how to verify it also has the additional button next to it, and that both buttons have the expected classes.

My issue is I need to find the button, with a specific class, adjacent to another button with a specific class. Psuedo code:

cy.contains('Not Met').and('has.class', 'btn-danger').next().contains('N/A).and('has.class', 'btn-tertiary')...and then somehow click the Not Met button :)

Viewing all articles
Browse latest Browse all 140762

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>