Jump to content

Need help for testcase fail over condition in Autoit.


Recommended Posts

Hi,

I want to know how we can rescue in Autoit.

What i mean is like, for eg i have 4 testcases.

Testcase1

find checkbox by name "allow" and click it

find checkbox by name "edit" and click it

Testcase2

find checkbox by name "allow2" and click it

find checkbox by name "copy" and click it

Testcase3

find checkbox by name "allow3" and click it

find checkbox by name "move" and click it

Testcase4

find checkbox by name "allow4" and click it

find checkbox by name "store" and click it

Now currently if i execute script and if in testcase1, script is not able to find checkbox "allow", it does not throw any error.

It just moved ahead with another line.

But what i want to do is like :

1. If it is not able to find any checkbox then it should skip this testcases and go to next testcases i.e. testcase2.

2. OR If it is not able to find any checkbox then simply call the cleanup function, which will close the current window and then go to next testcase.

How we can achieve this.

Im using Micro framework for unit test, so i created the testcases, but if test case fails then im not able to track it where it failed.

Any help is appreciated.

Thanks

Bhavesh

Link to comment
Share on other sites

@EndFunc :

Something like this i have :

;TEST1

ShellExecute("C:DataExcel_Docsprotfile1.xlsx")

call("WaitforWindow", "Microsoft Excel - file1")

$titletext = WinGetTitle("Microsoft Excel - file1")

$var1 = "fail"

If $titletext = "Microsoft Excel - file1" Then

FileWrite("result.txt", "TestCase : 0003 : Passed : Excel File Opened Properly" & @CRLF)

$var1 = "pass"

EndIf

If $var1 == "fail" Then

FileWrite("result.txt", "TestCase : 0003 : Failed : Excel File Not Opened Properly" & @CRLF)

EndIf

call("Close_MSWord")

;TEST2

ShellExecute("C:DataExcel_Docsprotfile2.xlsx")

call("WaitforWindow", "Microsoft Excel - file2")

$titletext = WinGetTitle("Microsoft Excel - file2")

$var1 = "fail"

If $titletext = "Microsoft Excel - file2" Then

FileWrite("result.txt", "TestCase : 0004 : Passed : Excel File Opened Properly" & @CRLF)

$var1 = "pass"

EndIf

If $var1 == "fail" Then

FileWrite("result.txt", "TestCase : 0004 : Failed : Excel File Not Opened Properly" & @CRLF)

EndIf

call("Close_MSWord")

Now if it is not able to open the file or if there is any other failure, i want this to move to next testcase.

I mean i can add cleanup setps and then ask the script to move to next text case or may be move to next line.

But im not sure how to verify that command which is executed is passed or failed.

Becasue in most of the cases we usually script to click some button, and if it is not found it just go ahead without any error that button is not found.

If i get such error that buton is not found then i will know that comman is not sucessfull and then i stop that testcase there only and ask script to move to next testcase.

Can anybody help.

Bhavesh

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...