cancel
Showing results for 
Search instead for 
Did you mean: 

If object exists then click on it an, if object does not exist go to next step: how to achieve this.

Highlighted
Frequent Contributor

If object exists then click on it an, if object does not exist go to next step: how to achieve this.

How do I do this " If object exists then click on it, if object does not exist go to next step " 

I am attaching the test screenshot in aword doc

 

5 REPLIES 5
Frequent Contributor

Re: If object exists then click on it, if object does not exist go to next step

 
Community Hero

Re: If object exists then click on it, if object does not exist go to next step

Well...  You don't need the "if not exists" line at all...  You can replace that with the "Else" operator... then you should actually "outdent" that entire block of code to the left so it executes on the same "level" as your if operater... otherwise...  I don't see anything wrong with what you posted....so... that means something is not happening that you are expecting to happen....  Please give us more details on what is going wrong.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Frequent Contributor

Re: If object exists then click on it, if object does not exist go to next step

If I right click and I select Insert New Opeartion I see Else condition but it has a red X on it.WhenI run the test it is catchinga n exception at that line.

Attaching teh screenshot again with Else clause added.

 

The earlier script (Before adding else) was works fine if the object "YES "is existing but it stops and does not execute when object "YES" is not existing.

Adding the file again with Else screenshot

Community Hero

Re: If object exists then click on it, if object does not exist go to next step

The red x on else is expected... it's simply the icon to use for the "Else" operation.  You should outdent that else to be on the same level as your initial if-then and then move your operations you want to execute within the Else statement.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Community Manager

Re: If object exists then click on it, if object does not exist go to next step

Hi All,

Thanks for the help, Robert.

 

@saranoor, do the suggestion given here help you resolve the issue? What was the solution?

---------
Tanya Gorbunova
SmartBear Community Manager

Join the September Hub-bub to show off, learn and win
New Here?
Join us and watch the welcome video:
Watch the New Interview
7Mistakes
Join the September Hub-bub to show off, learn and win