Forum Discussion

MarcusBengtsson's avatar
MarcusBengtsson
Frequent Contributor
2 years ago
Solved

IF .. then else issue

Hello! So I am having this problem with If .. Then and else

 

I am trying to make it so that IF this Testtemplatedetails exists it will run the steps below. But if it doesnt exist it should run else.

When I execute the steps it will jump down the the else part instantly. Ive checked with highlight that the "Testtemplatedetails" exists, which it does. So why does it skip it?

 

  • I'm not sure but it looks like in your If statement the 2nd condition is a string value.

     

    Also sould it not be "IF : 'Aliases.etc.etc.Exists EQAULS True'" ?

     

  • You have the following alias defined as Aliases.browser.TestTemplateDetails

     

    If you want to check if the object exists, then use the keyword "If Object" followed by as Aliases.browser.TestTemplateDetails = Exists.

     

    If you want to check a property of the object that exists, then use the keyword "If...Then" followed by Aliases.browser.TestTemplateDetails.Exists = True.

     

    Note, the Value

     

11 Replies

  • MW_Didata's avatar
    MW_Didata
    Regular Contributor

    I'm not sure but it looks like in your If statement the 2nd condition is a string value.

     

    Also sould it not be "IF : 'Aliases.etc.etc.Exists EQAULS True'" ?

     

    • MarcusBengtsson's avatar
      MarcusBengtsson
      Frequent Contributor

      Youre a bloody genious, thank you! When I changed to value1 .Exists at the end it worked!

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    You have the following alias defined as Aliases.browser.TestTemplateDetails

     

    If you want to check if the object exists, then use the keyword "If Object" followed by as Aliases.browser.TestTemplateDetails = Exists.

     

    If you want to check a property of the object that exists, then use the keyword "If...Then" followed by Aliases.browser.TestTemplateDetails.Exists = True.

     

    Note, the Value

     

    • MarcusBengtsson's avatar
      MarcusBengtsson
      Frequent Contributor

      But the thing is, when I did the "If Object" it searched for it, didnt find it. Failed the test.. Without continue further. Any settings needed to be changed to make this work? It worked with If .. Then. 

  • MW_Didata's avatar
    MW_Didata
    Regular Contributor

    This test checks if an object exists and changes a Variable to false

    Under else it set the variable to True

    This works for me 

     

    EDIT: for clarity, if the object does not exist then it just does the else condition, No error will be posted if the object does not exist, can you post e screenshot of how its configured now?

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Where in your keyword test, is it failing? And what is the error log?

    • MarcusBengtsson's avatar
      MarcusBengtsson
      Frequent Contributor

      Hmm weidly enought it seems to be working again? I dont even know why or how. Will continue the testing, thanks for the help today guys!

      • MW_Didata's avatar
        MW_Didata
        Regular Contributor

        No problem, make sure to test the else condition aswell when the object does not exist