Sign in to follow this  
Followers 0
slu

test validation and test suite

13 posts in this topic

Hi,

I am new to Autoit and have few general questions:

1. I created few au3 files and each of them is for a test case, how can I run them as a test suite?

2. When I run the test, how can I verify something like window title name, the contents in the window or other data?

3. Does anyone has experience to test MS Excel menu (not workbook in the Excel) using Autoit? May I have an example code? (not just use Send("$key").

Thanks,

Slu

Share this post


Link to post
Share on other sites



Hi Slu, welcome to the AutoIt Forums!

I would like to help you, but I really do not understand what you are trying to do?

Could you include more details and/or code that we could assist you with?

Thanks,

shanet


[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:
%programfiles%/AutoIt3/autoit3.chm

Share this post


Link to post
Share on other sites

Hi,

I am new to Autoit and have few general questions:

1. I created few au3 files and each of them is for a test case, how can I run them as a test suite?

2. When I run the test, how can I verify something like window title name, the contents in the window or other data?

3. Does anyone has experience to test MS Excel menu (not workbook in the Excel) using Autoit? May I have an example code? (not just use Send("$key").

Thanks,

Slu

Welcome to the forum

1.) You have two options, either put each test case as a function within one au3 file or put each test case in a separate au3 file (as you have done) then create another file that calls the functions in the other files (like the JUnit framework).

2.) Look in the help file for WinGetTitle or some of the tutorials around. There is a link in my Sig.

3.) There is a UDF for Excel, search the forum and you will find many topics on the subject.

Good luck


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

Thanks for the answers to my questions.

For question 1, I created another .au3 file which executes all my au3 files in sequence. In this way, the users (Product QA) can easily modify that file. If there is need to run different set of .au3 files on different products or platforms, I can put them in different config files and read config files according to the test needs. I also created some au3 files served as libraries, just as what you suggested.

Question 2: Looks like window title is easy to check, but the contents are hard, like some java programs. I only get title, but content is enpty.

Share this post


Link to post
Share on other sites

2. Have a look at ControlGetText. I recommend you use ControlGetHandle to get the control handle first.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

I made a thread because i was getting crazy about making a working test some time ago.

Here's a working code, feel free to use:

#include <GUIConstantsEx.au3>
TestLavoro();all the correct answer to the test here are the one WITH 1 in the name!
Func TestLavoro()
                                    Local $GUITestLavoro = GUICreate("Test Colloquio Lavorativo", 468, 643, 402, 7)
                                    GUICtrlCreateLabel("TEST DI IDONEITA' AL POSTO DI LAVORO", 48, 16, 377, 28)
                                    GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
                                    GUICtrlCreateLabel("Mi ra.", 104, 56, 282, 17)
                                    GUICtrlCreateLabel("1)", 8, 88, 17, 22)
                                    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
                                    GUIStartGroup()
                                    Local $LabelRadioDom1 = GUICtrlCreateLabel("dom1", 32, 88, 30, 17)
                                    Local $Radio1 = GUICtrlCreateRadio("Radio1", 8, 112, 425, 17)
                                    Local $Radio2 = GUICtrlCreateRadio("Radio2", 8, 136, 425, 17)
                                    Local $Radio3 = GUICtrlCreateRadio("Radio3", 8, 160, 425, 17)
                                    Local $Radio4 = GUICtrlCreateRadio("Radio4", 8, 184, 425, 17)
                                    GUICtrlCreateLabel("2)", 12, 211, 17, 20)
                                    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
                                    GUIStartGroup()
                                    Local $LabelRadioDom2 = GUICtrlCreateLabel("dom2", 36, 211, 30, 17)
                                    Local $Radio5 = GUICtrlCreateRadio("Radio1b", 12, 235, 425, 17)
                                    Local $Radio6 = GUICtrlCreateRadio("Radio2b", 12, 259, 425, 17)
                                    Local $Radio7 = GUICtrlCreateRadio("Radio3b", 12, 283, 425, 17)
                                    Local $Radio8 = GUICtrlCreateRadio("Radio4b", 12, 307, 425, 17)
                                    GUICtrlCreateLabel("3)", 12, 340, 17, 20)
                                    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
                                    GUIStartGroup()
                                    Local $LabelRadioDom3 = GUICtrlCreateLabel("dom3", 36, 340, 30, 17)
                                    Local $Radio9 = GUICtrlCreateRadio("Radio1c", 12, 364, 425, 17)
                                    Local $Radio10 = GUICtrlCreateRadio("Radio2c", 12, 388, 425, 17)
                                    Local $Radio11 = GUICtrlCreateRadio("Radio3c", 12, 412, 425, 17)
                                    Local $Radio12 = GUICtrlCreateRadio("Radio4c", 12, 436, 425, 17)
                                    GUICtrlCreateLabel("4)", 12, 462, 17, 20)
                                    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
                                    GUIStartGroup()
                                    Local $LabelRadioDom4 = GUICtrlCreateLabel("dom4", 36, 462, 30, 17)
                                    Local $Radio13 = GUICtrlCreateRadio("Radio1d", 12, 486, 425, 17)
                                    Local $Radio14 = GUICtrlCreateRadio("Radio2d", 12, 510, 425, 17)
                                    Local $Radio15 = GUICtrlCreateRadio("Radio3d", 12, 534, 425, 17)
                                    Local $Radio16 = GUICtrlCreateRadio("Radio4d", 12, 558, 425, 17)
                                    Local $BottoneScappaTest = GUICtrlCreateButton("Scappa....", 8, 592, 177, 41)
                                    Local $BottoneConsegnaTest = GUICtrlCreateButton("Consegna il test", 280, 592, 177, 41)
                                    Local $CompilaTest = ColloquioDomande()
                                    GUICtrlSetData($LabelRadioDom1, $CompilaTest[0][0])
                                    GUICtrlSetData($LabelRadioDom2, $CompilaTest[0][1])
                                    GUICtrlSetData($LabelRadioDom3, $CompilaTest[0][2])
                                    GUICtrlSetData($LabelRadioDom4, $CompilaTest[0][3])
                                    GUICtrlSetData($Radio1, $CompilaTest[1][0])
                                    GUICtrlSetData($Radio2, $CompilaTest[1][1])
                                    GUICtrlSetData($Radio3, $CompilaTest[1][2])
                                    GUICtrlSetData($Radio4, $CompilaTest[1][3])
                                    GUICtrlSetData($Radio5, $CompilaTest[1][4])
                                    GUICtrlSetData($Radio6, $CompilaTest[1][5])
                                    GUICtrlSetData($Radio7, $CompilaTest[1][6])
                                    GUICtrlSetData($Radio8, $CompilaTest[1][7])
                                    GUICtrlSetData($Radio9, $CompilaTest[1][8])
                                    GUICtrlSetData($Radio10, $CompilaTest[1][9])
                                    GUICtrlSetData($Radio11, $CompilaTest[1][10])
                                    GUICtrlSetData($Radio12, $CompilaTest[1][11])
                                    GUICtrlSetData($Radio13, $CompilaTest[1][12])
                                    GUICtrlSetData($Radio14, $CompilaTest[1][13])
                                    GUICtrlSetData($Radio15, $CompilaTest[1][14])
                                    GUICtrlSetData($Radio16, $CompilaTest[1][15])
                                    GUICtrlSetState($Radio1,$GUI_CHECKED)
                                    GUICtrlSetState($Radio5,$GUI_CHECKED)
                                    GUICtrlSetState($Radio9,$GUI_CHECKED)
                                    GUICtrlSetState($Radio13,$GUI_CHECKED)
                                    GUISetState(@SW_SHOW)
                                    While 1;While test lavoro
                                        $SceltaGUITestLavoro = GUIGetMsg()
                                        Switch $SceltaGUITestLavoro
                                            Case $GUI_EVENT_CLOSE
                                                Exit
                                            Case $BottoneConsegnaTest
                                                Local $k=$Radio1;primo numer ciclo for radio 1, poi viene cambiato
                                                Local $RispCorr[4];verrà riempito con le id dei radio corretti
                                                Local $GiroDomCorr=0;Se viene trovata stringa della risp corretta, aumenta, è l'indice dell'array $Rispcorr
                                                For $e=1 to 4;per 4 volte esamina i gruppi di radio, funziona xk il for sotto viaggia con gli ID dei radio
                                                    For $i=$k To $i+3;Questa va con gli id dei radio incrementati appena fuori da questo ciclo con k+=6
                                                        Local $Corr=GUICtrlRead($i,1);legge gli id suggeriti dal ciclo sopra (modalità avanzata "$i,1)". Radio1=7 e cosi via
                                                        If $Corr="a1" Or $Corr="b1" Or $Corr="c1" Or $Corr="d1" Or $Corr="e1" Then;Se leggendo il controllo trovo il testo corretto
                                                            $RispCorr[$GiroDomCorr]=$i;allora rispostacorretta(giro) è uguale all'id di quel radio con la risp corretta
                                                            $GiroDomCorr+=1;e quindi aumento il giro (che è anche l'indice dell'array con le risp corrette) di 1.
                                                        EndIf;I CONTROLLI IN AUTOIT INIZIANO SEMPRE DA 3, Quindi anche se in una gui vuota metto un solo label o radio l'ID è 3.
                                                    Next
                                                    $k+=6;Si aumenta di 6 k, che è = a i nel giro For, perchè anche i label di testo contano come controlli e tra i vari radio
                                                Next;C'e 1) e DomA, 2) e DomB quindi si aumenta di 4 (i radio) + 2 (numero domanda e testo domanda) e si riarriva al prossimo radio.
                                                Local $PunteggioTest=0; Punteggio per vedere se è passato il test
                                                For $z=0 To 3
                                                    If GUICtrlRead($RispCorr[$z])=$GUI_CHECKED Then $PunteggioTest+=1
                                                Next
                                                If $PunteggioTest=4 Then
                                                    MsgBox(0,"Passed","Passed")
                                                    ExitLoop
                                                ElseIf $PunteggioTest=3 Then
                                                    Local $rand=Random(1,10,1)
                                                    If $rand>7 Then
                                                        MsgBox(0,"Passed","Passed")
                                                        ExitLoop
                                                    Else
                                                        MsgBox(0,"not Passed","not Passed")
                                                        ExitLoop
                                                    EndIf
                                                Else
                                                    MsgBox(0,"not Passed","not Passed")
                                                    ExitLoop
                                                EndIf
                                        EndSwitch
                                    WEnd;Wend Test Lavoro
EndFunc

Func ColloquioDomande()
    Local $DomandaA[5] = ["domA", "a1", "a2", "a3", "a4"], $DomandaB[5] = ["domB", "b1", "b2", "b3", "b4"], $DomandaC[5] = ["domC", "c1", "c2", "c3", "c4"] _
            , $DomandaD[5] = ["domD", "d1", "d2", "d3", "d4"], $DomandaE[5] = ["domE", "e1", "e2", "e3", "e4"]
    Local $aArrays[5] = [$DomandaA, $DomandaB, $DomandaC, $DomandaD, $DomandaE]
    _ArrayShuffle($aArrays)
    Local $MultiDomERisp[2][16], $aTemp, $num = 0
    For $iArrNo = 0 To 3
        $aTemp = $aArrays[$iArrNo]
        _ArrayShuffle($aTemp, 1)
        $MultiDomERisp[0][$iArrNo] = $aTemp[0]
        For $x = 1 To UBound($aTemp) - 1
            $MultiDomERisp[1][$num] = $aTemp[$x]
            $num += 1
        Next
    Next
    Return $MultiDomERisp
EndFunc ;==>ColloquioDomande

; http://www.autoitscript.com/forum/index.php?s=&showtopic=79564&view=findpost&p=573531
Func _ArrayShuffle(ByRef $aArray, $iBase = 0, $iUBound = Default)
    If Not IsArray($aArray) Then Return SetError(1, 0, 0)
    If UBound($aArray, 0) <> 1 Then Return SetError(2, 0, 0)
    Local $temp, $rand
    If $iUBound = Default Or $iUBound = 0 Then $iUBound = UBound($aArray) - 1
    For $i = $iBase To $iUBound
        $temp = $aArray[$i]
        $rand = Random($iBase, $iUBound, 1)
        $aArray[$i] = $aArray[$rand]
        $aArray[$rand] = $temp
    Next
EndFunc ;==>_ArrayShuffle

and here's my 2 post about it:

Bye, hope it helps


I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Share this post


Link to post
Share on other sites

2. Have a look at ControlGetText. I recommend you use ControlGetHandle to get the control handle first.

My product under test is a MS Excel add-in, and other programs launched from Excel are either dotnet or java program.

Most controls functions need to know controlID, but I am not sure what is controlID in our java program. I tried to use TEXT - The text on a control, for example "&Next" on a button, but still got empty string from ControlGetText or empty handler from ControlGetHandle.

Any help is appreciated.

Share this post


Link to post
Share on other sites

The control information, like the controlID and be sourced from the AutoIt Info tool. I like to pause the tool then drag the pointer over the control I am interested in to get the information. From there, put the control information int ControlGetHandle. The tool 'Control Handle under mouse' in my sig does something similar to the info tool.

Post code if you have any issues and don't forget to put in error handling (looking at @error) after ControlGetHandle.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

AutoIt Info tool does not for our java programs, only works for our other programs written in dotnet.

Share this post


Link to post
Share on other sites

You are correct. I tested it out with JMeter and it only gets the window. AutoIt works more that just donnet, don't assume otherwise.

For your Java issues, I recommend you look at might have what you need.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

I tried following this java UDF link to install the program few days ago, but not able to run JavaFerret.exe (could not get any error output, either command outpur or system event).

I havd one problem about steps from the UDF link that the downloaded Java Access Bridge only have three jaccess-1_x.jar files. There are for java 1.2, 1.3 and 1.4. My java version is v1.6. I am not sure the failure of JavaFerret.exe running is due to this.

Hava you successfully run JavaFerret.exe and got jva window info?

Share this post


Link to post
Share on other sites

Sorry mate, I have not tried it out. I can only recommend you post in seangriffin's thread and hope he can have a look.

They only other suggestion is using mousemove and send, sorry.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

You are correct. I tested it out with JMeter and it only gets the window. AutoIt works more that just donnet, don't assume otherwise.

For your Java issues, I recommend you look at might have what you need.

Thanks.

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