CaptainBeardsEyesBeard Posted July 4, 2018 Share Posted July 4, 2018 For example if you look at one of my tests you can see I'm just doing MouseClicks and SEND commands to input data. But for example how would I write a test like you would in C# with Try/CAtch for eg: Try {click_a_field} Catch (exception) {If can't click this exact field exit test} expandcollapse popupFUNC TEST10_Add_Costs_To_A_Matter($MatterNumber, $DateWorked, $Timekeeper, $Currency, $LocationCode, $CostCode, $Rate, $AuthorisedTax) Navigation_Click_Billing_Manager() Navigation_Click_Billing_Manager_Costs() Navigation_Click_Billing_Manager_Costs_CostsEntry() WinActivate("Cost Entry") ; Focus Time window Sleep(2000) ;Click Go button Send("{TAB}") Sleep(1000) Send("{ENTER}") Sleep(2000) WinActivate("New Costcard") ; Focus Time window Sleep(4000) Send($MatterNumber) Send("{TAB}") Sleep(3000) Send($DateWorked) Send("{TAB}") Sleep(1000) Send($Timekeeper) Send("{TAB}") Sleep(5000) Send($Currency) Sleep(3000) If ($Currency = "AUSD" OR $Currency = "EUR" OR $Currency = "CAN" OR $Currency = "HKD" OR $Currency = "NZD") then Send("{TAB}") Sleep(1000) Send($Rate) Sleep(1000) Send("{TAB}") Sleep(1000) Send($Rate) Send("{TAB}") Sleep(1000) Else EndIf Sleep(1000) Sleep(1000) ;Send($LocationCode) Send("{TAB}") Send("{TAB}") Sleep(1000) Send("{Down}") Send("{TAB}") Sleep(1000) Send($CostCode) Send("{TAB}") Sleep(1000) ;Send($AuthorisedTax) Send("{TAB}") Send($Rate) Sleep(3000) Local $hWnd = WinWait("Cost Entry", "", 10) ;obtain the text in that window which should be "Successfully Saved records for RSA1" Local $RecordSaveSuccess = ControlGetText($hWnd, "", "ThunderRT6FormDC") Sleep(1000) if StringInStr($RecordSaveSuccess, $MatterNumber) then MsgBox($MB_SYSTEMMODAL, "Test" & $TestCount & " Result", "Test Passed, Timekeeper Saved", 4) FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new Cost entry using " & $MatterNumber& " Ensure Timekeeper saves " & $RecordSaveSuccess & " Test Passed") Else MsgBox($MB_SYSTEMMODAL, "Test" + $TestCount & " Result", "Test Failed", 4) FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new Cost entry using " & $MatterNumber& " Ensure timekeeper saves Test Failed" & $RecordSaveSuccess) EndIf Sleep(1000) ControlClick("New Costcard", "", "[CLASS:ThunderRT6CommandButton; INSTANCE:7;]") ;click ok Sleep(1000) WinActivate("New Costcard") ; Focus Time window Sleep(1000) WinClose("New Costcard") ; Close window Sleep(1000) WinActivate("Cost Entry") ; Focus Time window Sleep(1000) WinClose("Cost Entry") ; Close window Navigation_Click_Billing_Manager_Costs() Navigation_Click_Billing_Manager() $TestCount = $TestCount + 1 EndFunc Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted July 4, 2018 Share Posted July 4, 2018 5 hours ago, CaptainBeardsEyesBeard said: But for example how would I write a test like you would in C# with Try/CAtch for eg: Try {click_a_field} Catch (exception) {If can't click this exact field exit test} If, Return Values, @error codes... Best Regards. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Earthshine Posted July 4, 2018 Share Posted July 4, 2018 could also use a switch statement My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
orbs Posted July 4, 2018 Share Posted July 4, 2018 for the OP using mainly Send(), checking @error and return value is moot - Send() does not return any, see the help file. when sending text into input fields of a foreign application, off-hand i'd say the proper validation method would be to capture the text of the window - i.e. WinGetText() - before and after the insertion of text, so you can see that the desired text was indeed typed in, and in the desired position. this may not always be possible, and requires a considerable amount of trial and error. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
jdelaney Posted July 4, 2018 Share Posted July 4, 2018 (edited) That's a great question to becoming a good automater. ..rather than just doing actions and expecting an outcome, you can do an action and verify the outcome. rinse and repeat if failed. It's much easier to do with controlsettext and controlgettext Edited July 4, 2018 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Earthshine Posted July 4, 2018 Share Posted July 4, 2018 i wrap the functions, like with that WaitForControls stuff, that logs everything. My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted July 5, 2018 Author Share Posted July 5, 2018 (edited) Ah thanks. Wrapping functions in wait controls should be what I'm doing. I've seen the @error thing before but unsure how to use it. Could you provide an example? Edit: Also is there a way to "Exit" a function so if one test fails it just continues to the next? Edited July 5, 2018 by CaptainBeardsEyesBeard Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted July 5, 2018 Share Posted July 5, 2018 @CaptainBeardsEyesBeard Local $strInputBox = InputBox("InputBox", "Type Text here:") If @error = 1 Then MsgBox($MB_ICONINFORMATION, "", "The Cancel button has been pressed.") Else ; Instructions... EndIf Best Regards. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Earthshine Posted July 5, 2018 Share Posted July 5, 2018 (edited) as long as you can intercept the error you can log it and move on, yes I posted a snippet, not a real UDF by any means, but it can be expanded to wrap other controls, WaitForControls.au3 which uses log4a.au3 for logger. Edited July 5, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
jdelaney Posted July 5, 2018 Share Posted July 5, 2018 (edited) Although more complex, I setup an infrastructure where I could pass in a variable of the test to run. that way, If something does error out, the other tests can still be executed. if they are all stringed together in one script, that is not possible. it also makes debugging or reruning a specific test much easier Edited July 5, 2018 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now