0

I'm having an issue occur when I try to use the if statement with multiple conditions in the Selenium IDE. One of the conditions always seems to get ignored.

Here's my scenario:

if     |     !selenium.isElementPresent("link=userA") && !selenium.isElementPresent("link=userB")
    goto     |     SETUP_DONE

else
    if     |     selenium.isElementPresent(""link=userA")
        clickAndWait     |     link=userA
        clickAndWait     |     name=deleteuser
        clickAndWait     |     name=deleteuser
    endIf

    if     |     selenium.isElementPresent("link=userB")
        clickAndWait     |     link=userB
        clickAndWait     |     name=deleteuser
        clickAndWait     |     name=deleteuser
    endIf

    label     |     SETUP_DONE
    waitForElementNotPresent     |     link=userA
    waitForElementNotPresent     |     link=userB
endIf

Basically, my script is suppose to check for the existence of two users. If neither one exists, then then it jumps to the label SETUP_DONE where it will perform some other tests. If either user is detected, then it clicks on the link of the user that's detects, deletes the user('s), and reverifies that neither of the two user names exist.

However, as the code is now, it only verifies userA and the verification of userB is completely ignored. If I change the statement to...

if     |     !selenium.isElementPresent("link=userA" && "link=userB")

...then it ignores the first user, userA, and checks for userB. I tried using "&" and "and" instead, but those resulted in the script failing. Does anyone know how my syntax is wrong and what it should be? Will I have to create a separate check for each username instead of combining the check on one line of code? Thanks ahead of time.

2
  • To do IF's you have a plug in installed. If you really need this functionality you should consider moving out of the IDE into webdriver world. Commented Jan 15, 2015 at 22:26
  • Thanks for your response, @DMart. I did end up exporting my test cases over to Webdriver, in Python. I still thought this could be a good question being it's a basic concept of coding. Commented Jan 22, 2015 at 15:24

1 Answer 1

1

Up to this point, I've never found a solution that allowed me to include multiple arguments in a IF statement on selenium IDE. However, this is a solution to handle this problem until multiple arguments can be used:

if       |   !selenium.isElementPresent("link=userA")
     goto     |   NEXT_AND_COND
else
     goto     |   AND_COND_NOT_MET
endIf
label    |   NEXT_AND_COND
if       |   !selenium.isElementPresent("link=userB")
     goto     |   SETUP_DONE
else
     label    |   AND_COND_NOT_MET
     if       |   selenium.isElementPresent(""link=userA")
          clickAndWait   |   link=userA
          clickAndWait   |   name=deleteuser
          clickAndWait   |   name=deleteuser
     endIf
     if       |   selenium.isElementPresent("link=userB")
          clickAndWait   |   link=userB
          clickAndWait   |   name=deleteuser
          clickAndWait   |   name=deleteuser
     endIf
endIf
label    |   SETUP_DONE
waitForElementNotPresent   |   link=userA
waitForElementNotPresent   |   link=userB
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.