Sign in to follow this  
Followers 0
rynodyno

Software Testing

21 posts in this topic

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!

Share this post


Link to post
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")

Share this post


Link to post
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.

Share this post


Link to post
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!!!

Share this post


Link to post
Share on other sites

thank you buddy!! will get on it straight away!!!

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Why not lookup _FileWriteLog. It is a more reliable form for putting down any kind of error.log or even *.txt


Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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…

Share this post


Link to post
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...

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

@zfisherdrums,

I almost quoted that in this post

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

but the help file is not clear if that applies to built in functions, UDFs or both.

My testing seems to point to both.

Edited by herewasplato

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

Share this post


Link to post
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")

Share this post


Link to post
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!

Share this post


Link to post
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!

Share this post


Link to post
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!

Share this post


Link to post
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!

Share this post


Link to post
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…

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

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

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

PLATOOO!!! it's working mate.. there are a quite a few lines written for each error and I need to continue with the script, but i should be able to figure it out.. .thanks a million for your help!!

Share this post


Link to post
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
Sign in to follow this  
Followers 0