Jump to content

Software Testing


Recommended Posts

Hi all!

I'm new to autoit (2 weeks!) and have been practicing automating my test scripts for an in-house built software.. i just want to know (i'm not expecting anyone to do the coding for me!) if it is possible to also log errors or any other exceptions while these tests are running in autoit?? and maybe tell me in words how i would go about doing it?

i know this mite be a bit too much to ask but even telling me keywords of what to research on or any useful topcis/links i should follow up will be of great help!

eagerly waiting for replies...

ryan!

Link to comment
Share on other sites

Hi all!

I'm new to autoit (2 weeks!) and have been practicing automating my test scripts for an in-house built software.. i just want to know (i'm not expecting anyone to do the coding for me!) if it is possible to also log errors or any other exceptions while these tests are running in autoit?? and maybe tell me in words how i would go about doing it?

i know this mite be a bit too much to ask but even telling me keywords of what to research on or any useful topcis/links i should follow up will be of great help!

eagerly waiting for replies...

ryan!

This is the code i have so far... the script keeps running until the program is closed even if there were errors :-(

; Script Start - start synergetic

Run ("S:\TCMVIC\Trial_CD_August\Synergetic\SynMain.exe arose")

WinWaitActive("Information")

send("{enter}")

;Login

WinWaitActive("Synergetic Login")

Send("+{TAB}")

Send("{DEL}")

Send("sa")

Send("{TAB}")

Send("hersql3{#}")

Send("{enter}")

;Create Course

Sleep(500)

send("!M")

Sleep(500)

send("S")

Sleep(500)

send("U")

Sleep(500)

WinWaitActive("Set Course Search Criteria")

Send("!N");New course

Send ("F");Campus

Sleep(100)

Send("{Enter}")

Send("{TAB}")

Send("Test 1");Course Name

Send("{TAB}")

Send("Auto Generated Test course");Course Description

Send("{Enter}")

Send("!N");Dates

Send("!N");Charges

Send("!N");Classes

Send("!N");Students

Send("!N");UserForms

Send("!N");Semester Dates Override

Send("!N");Additional

Send("!O")

Send("^{TAB}")

Send("{ESC}")

;Course Created

;Delete course

Sleep(1000)

send("!M")

Sleep(500)

send("S")

Sleep(500)

send("U")

Sleep(500)

WinWaitActive("Set Course Search Criteria")

Send("F")

Send("{Enter}")

sleep(800)

Send("{PGDN 5}")

Send("^d")

WinWaitActive("Confirm Delete")

Send("Delete")

Send("{ENTER}")

Sleep(2000)

Send("Y")

Send("{Enter}")

WinWaitActive("Set Course Search Criteria")

send("{ESC}")

WinWaitActive("Synergetic Management System for Schools [arose]")

Send("{LEFT 3}")

Send("{Enter}")

;Close Synergetic

WinWaitActive("Synergetic Management System for Schools [arose]")

Send("!C")

Send("!F")

sleep(100)

Send("x")

winwaitactive("Confirm")

Send("Y")

Link to comment
Share on other sites

You could try this:

#include <File.au3>

Func _Error()
    If @error Then
        $Error_File = _FileCreate("error.log")
        FileWriteLine($Error_File, @error)
        MsgBox(32, "Error", "Error logged as: " & @error)
    EndIf
    If FileExists($Error_File Then
        FileWriteLine($Error_File, @error)
        MsgBox(32, "Error", "Error logged as: " & @error)
    EndIf
Else
    If $Error_File = @error Or $Error_File = -1 Then MsgBox(4096, "Error", "Log failed to be created")
Hope that helps, Clipper34.

Link to comment
Share on other sites

You could try this:

#include <File.au3>

Func _Error()
    If @error Then
        $Error_File = _FileCreate("error.log")
        FileWriteLine($Error_File, @error)
        MsgBox(32, "Error", "Error logged as: " & @error)
    EndIf
    If FileExists($Error_File Then
        FileWriteLine($Error_File, @error)
        MsgBox(32, "Error", "Error logged as: " & @error)
    EndIf
Else
    If $Error_File = @error Or $Error_File = -1 Then MsgBox(4096, "Error", "Log failed to be created")
Hope that helps, Clipper34.
thank you buddy!! will get on it straight away!!!
Link to comment
Share on other sites

FileWrite()

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Link to comment
Share on other sites

The file still does not get created.. i even tried the 'dircreate' function instead of _filecreate..

FileWrite is the alternative solution

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Link to comment
Share on other sites

You could try this:

#include <File.au3>

Func _Error()
    If @error Then
        $Error_File = _FileCreate("error.log")
        FileWriteLine($Error_File, @error)
        MsgBox(32, "Error", "Error logged as: " & @error)
    EndIf
    If FileExists($Error_File Then
        FileWriteLine($Error_File, @error)
        MsgBox(32, "Error", "Error logged as: " & @error)
    EndIf
Else
    If $Error_File = @error Or $Error_File = -1 Then MsgBox(4096, "Error", "Log failed to be created")
Hope that helps, Clipper34.
hello it's my first post here.

i think it have same pbs with this code, dont U think so ??

#include <File.au3>

Func _Error()
    If @error Then
        If NOT FileExists($Error_File) Then
            $Error_File = _FileCreate("error.log") ; we create file here, maybe U could use filewrite ...
        EndIf
        FileWriteLine($Error_File, @error)
        MsgBox(32, "Error", "Error logged as: " & @error)
    EndIf
      Else
    If $Error_File = @error Or $Error_File = -1 Then MsgBox(4096, "Error", "Log failed to be created")

so test this and we'll see :P

Edited by tig8drag

tester under construction ... please waitÂ…

Link to comment
Share on other sites

hello it's my first post here.

i think it have same pbs with this code, dont U think so ??

#include <File.au3>

Func _Error()
    If @error Then
        If NOT FileExists($Error_File) Then
            $Error_File = _FileCreate("error.log"); we create file here, maybe U could use filewrite ...
        EndIf
        FileWriteLine($Error_File, @error)
        MsgBox(32, "Error", "Error logged as: " & @error)
    EndIf
      Else
    If $Error_File = @error Or $Error_File = -1 Then MsgBox(4096, "Error", "Log failed to be created")

so test this and we'll see :P

How come no one has EndFunc at the end?! just left it out? or is it not necessary!??! trying it both ways... been working on this for 8 hours now... very... frustrating...
Link to comment
Share on other sites

How come no one has EndFunc at the end?! just left it out? or is it not necessary!??! trying it both ways... been working on this for 8 hours now... very... frustrating...

From the Help File:

When entering a function @error is set to 0.

Because of this, the error path is never hit in the "_ERROR" function. You would need to check the error macro after each statement that has the possibility of failing. You could wrap repeated actions into functions that internally check the status of the error macro. If an error occurs within the function, you could then call a fatal exception function.

Zach...

Link to comment
Share on other sites

From the Help File:

Because of this, the error path is never hit in the "_ERROR" function. You would need to check the error macro after each statement that has the possibility of failing. You could wrap repeated actions into functions that internally check the status of the error macro. If an error occurs within the function, you could then call a fatal exception function.

Zach...

the _ERROR function is being hit now thanks to @herewasplato!! but i'm getting an error "incorrect number of parameters in function call"

and i don't see anything wrong with my code!!

here it is:

#include <File.au3>

$file = FileOpen("\\zeus\$rfernando\Test Scripts\Automatic Testing\test.txt", 9)

AdLibEnable("_Error")

; Script Start - start synergetic

Run ("S:\TCMVIC\Trial_CD_August\Synergetic\SynMain.exe arose")

WinWaitActive("Information")

send("{enter}")

;Login

WinWaitActive("Synergetic Login")

Send("+{TAB}")

Send("{DEL}")

Send("sa")

Send("{TAB}")

Send("hersql3{#}")

Send("{enter}")

;Create Staff Member

Sleep(500)

send("!M")

Sleep(500)

send("H")

Sleep(500)

send("S")

Sleep(500)

WinWaitActive("Set Staff Search Criteria")

Send("!N");New Staff Member

------------ERROR OCCURS HERE--------------

WinWaitActive("Create New Staff Member")

Send("MR")

Send("{Enter}")

Send("{Enter}")

FileClose($file)

Func _Error()

If WinExists("DataTools Rapid Addressing Tool") Then FileWriteLine($file, @MON & @MDAY & " " & @HOUR & @MIN & @SEC & " I am done:" & @ComputerName, @CR)

EndFunc

;Close Synergetic

WinWaitActive("Synergetic Management System for Schools [arose]")

Send("!C")

Send("!F")

sleep(100)

Send("x")

winwaitactive("Confirm")

Send("Y")

Link to comment
Share on other sites

From the Help File:

Because of this, the error path is never hit in the "_ERROR" function. You would need to check the error macro after each statement that has the possibility of failing. You could wrap repeated actions into functions that internally check the status of the error macro. If an error occurs within the function, you could then call a fatal exception function.

Zach...

zach i don't think it's a problem with the macro's.. i replaced the macro's with some simple text, and it still gives me an autoit error... the "line" part of the filewriteline doesn't seem to work no matter what i do!

Link to comment
Share on other sites

From the Help File:

Because of this, the error path is never hit in the "_ERROR" function. You would need to check the error macro after each statement that has the possibility of failing. You could wrap repeated actions into functions that internally check the status of the error macro. If an error occurs within the function, you could then call a fatal exception function.

Zach...

zach i don't think it's a problem with the macro's.. i replaced the macro's with some simple text, and it still gives me an autoit error... the "line" part of the filewriteline doesn't seem to work no matter what i do!

Link to comment
Share on other sites

From the Help File:

Because of this, the error path is never hit in the "_ERROR" function. You would need to check the error macro after each statement that has the possibility of failing. You could wrap repeated actions into functions that internally check the status of the error macro. If an error occurs within the function, you could then call a fatal exception function.

Zach...

zach i don't think it's a problem with the macro's.. i replaced the macro's with some simple text, and it still gives me an autoit error... the "line" part of the filewriteline doesn't seem to work no matter what i do!

Link to comment
Share on other sites

From the Help File:

Because of this, the error path is never hit in the "_ERROR" function. You would need to check the error macro after each statement that has the possibility of failing. You could wrap repeated actions into functions that internally check the status of the error macro. If an error occurs within the function, you could then call a fatal exception function.

Zach...

zach i don't think it's a problem with the macro's.. i replaced the macro's with some simple text, and it still gives me an autoit error... the "line" part of the filewriteline doesn't seem to work no matter what i do!

Link to comment
Share on other sites

How come no one has EndFunc at the end?! just left it out? or is it not necessary!??! trying it both ways... been working on this for 8 hours now... very... frustrating...

yes it's necessary, also, i think your function still incomplete and i don't understand this condition : If $Error_File = @error Or $Error_File = -1 .... can U explain more about the pb ??

here i tried to close the 'if' statements ...

#include <File.au3>

Func _Error()
    If @error Then
        If NOT FileExists($Error_File) Then
            $Error_File = _FileCreate("error.log"); we create file here, maybe U could use filewrite ...
        EndIf
        FileWriteLine($Error_File, @error)
        MsgBox(32, "Error", "Error logged as: " & @error)
  Else
      If $Error_File = @error Or $Error_File = -1 Then MsgBox(4096, "Error", "Log failed to be created")
      EndIf
  EndIf
EndFunc

tray this... good luck !!!

tester under construction ... please waitÂ…

Link to comment
Share on other sites

...

the _ERROR function is being hit now thanks to @herewasplato!! but i'm getting an error "incorrect number of parameters in function call"

and i don't see anything wrong with my code!!...

two threads - same problem - gets confusing. see here:

http://www.autoitscript.com/forum/index.ph...st&p=562841

[size="1"][font="Arial"].[u].[/u][/font][/size]

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...