Automating some tests with Cypress, I've found this issue.
We are asking many questions to the customers and these question will appear one-by-one depending on the previous answers. The next question (and for instance the kind of answer) will be unknown until it is shown. I leave this here as an example in which every 'div' (not 'rootDiv') is a question and they are only shown when the previous one has been responded.
<div class="rootDiv">
<div class="type1">
<div class="type1b">
<button class="button1">
<button class="button1">
</div>
</div>
<div class="type2">
<div class="type2b">
<button class="button2">
<button class="button2">
<button class="button2">
<button class="button2">
</div>
</div>
<div class="type1">
<div class="type1b">
<button class="button1">
<button class="button1">
</div>
</div>
.
.
.
<div class="typeX">
<div class="typeXb">
<button class="buttonX">
<button class="buttonX">
<button class="buttonX">
<button class="buttonX">
</div>
</div>
</div>
So the issues I am facing are:
- Is there a way to access to the last 'div' within 'rootDiv', check its class and based on it click any of the buttons?
- Is there a way to get the 'text' written on the buttons of the last 'div'?
- Is there a way to have a list of elements (buttons in this case) and iterate through them?
There are many options to solve it, the main problem relies on how to get to those elements
Aucun commentaire:
Enregistrer un commentaire