0

I have a problem with Selenium IDE If-Else processing. My script is ignoring the logic and running both the If and the Else.

I want the script to check whether I have a single item or a group in my cart. If I have a single item, I want to do the single item delete, and if I have a group, I want to do the group delete.

If I have a single item, my script is doing the single item delete, then it goes on to do the group delete and fails the test with an element not found error.

The code of my if-else is below. What am I doing wrong?

<!-- ${Deletes} is set earlier -->
<tr>
    <td>gotoIf</td>
    <td>${Deletes}==true</td>
    <td>Stepssingle</td>
</tr>
<tr>
    <td>gotoIf</td>
    <td>${Deletes}==false</td>
    <td>Stepsgroup</td>
</tr>
<tr>
    <td>label</td>
    <td>Stepssingle</td>
    <td></td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>link=Delete</td>
    <td></td>
</tr>
<tr>
    <td>echo</td>
    <td>Delete Value: ${Deletes}</td>
    <td></td>
</tr>
<tr>
    <td>storeElementPresent</td>
    <td>link=Delete</td>
    <td>Deletes</td>
</tr>
<tr>
    <td>pause</td>
    <td>10000</td>
    <td></td>
</tr>
<tr>
    <td>label</td>
    <td>End</td>
    <td></td>
</tr>
<tr>
    <td>label</td>
    <td>Stepsgroup</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>css=a.button.delete-share</td>
    <td></td>
</tr>
<tr>
    <td>pause</td>
    <td>5000</td>
    <td></td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>xpath=(//button[@type='button'])[2]</td>
    <td></td>
</tr>
<tr>
    <td>echo</td>
    <td>Delete Value: ${Delete}</td>
    <td></td>
</tr>
<tr>
    <td>storeElementPresent</td>
    <td>css=a.button.delete-share</td>
    <td>Delete</td>
</tr>
<tr>
    <td>storeElementPresent</td>
    <td>link=Delete</td>
    <td>Deletes</td>
</tr>
<tr>
    <td>label</td>
    <td>End</td>
    <td></td>
</tr>
  • I have reworded your question to make it clearer. – Kate Paulk May 18 '17 at 11:42
1

I can see two major potential problems here.

First: You don't have if-else logic. You have two consecutive if statements which will be run one after the other.

Second: Your second if statement is run after the value of your Deletes variable is changed from true to false.

From what I saw in a quick websearch your if-else code should be more along these lines (syntax may not be correct):

|gotoIf|${Deletes==true}|Stepssingle|
|else|||
|gotoLabel|Stepsgroup||
|endif|||

Alternatively, you could use a more direct if-else structure.

|if|${Deletes==true}||
|gotoLabel|Stepsgroup||
|else|||
|gotoLabel|Stepsgroup||
|endif|||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.