Jump to content

crushyna

Members
  • Posts

    8
  • Joined

  • Last visited

About crushyna

  • Birthday June 15

Profile Information

  • Location
    Poland, Poznań

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

crushyna's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Hi everyone! I'm developing small testing tool for new software in my company. Tool itself is working correctly (it follows scripted test commands one by one), but I'm trying to develop an error checking function. Mechanics are simple: every time software (external) shows specific error (via window class), program asks for next step. Continue, or abort test (and return to main GUI)? The error check function is switched on/off via Checkbox in GUI. Here are some code fragments: Checkbox: Global $idCheckbox1 = GUICtrlCreateCheckbox("Enable TP.net error handling", 352, 40, 249, 17) GUICtrlSetFont(-1, 12, 400, 0, "Calibri") GUICtrlSetColor(-1, 0x000000) Checkbox switch: GUISetState(@SW_SHOW) Local $Choosen While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idCheckbox1 If _IsChecked($idCheckbox1) Then $cSwitch1 = 1 Else $cSwitch1 = 0 EndIf Case $idAddTest (and so on...) Function call: (alot of ElseIf commands...) ElseIf $aItem = $idOperatorIn Then WywolanieOkna() WinActivate($hFSO) ControlClick($hFSO, "", "[NAME:lblCashierNumber]") Sleep($Sleep_05) Send("0000019{Enter}19{Enter 2}") Sleep($Sleep_75) EndIf #EndRegion ### START ELSEIF ARMY ### Next If $cSwitch1 = 1 Then MsgBox( 0, "Error check!", "Error check ON!") /// just for testing purposes CheckError() Else Return EndIf EndSwitch WEnd Classic _IsChecked function: Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked And Checkerror() function itself: Func CheckError() Local $Answer If ControlCommand($hMsgPanel, "", "[NAME:panelMsgBox]", "IsEnabled", "") Then ;~ Sleep($Sleep_05) $Answer = MsgBox(52, "Error!", "An error occured! Continue testing?") ;~ Sleep($Sleep_05) Switch $Answer Case 6 MsgBox(0, "Error!", "Test will now continue.", 3) Send("{Enter}") WinActivate($hWnd) Return Case 7 MsgBox(64, "Error!", "Test cancelled.", 5) $ElseIfArmyOff = 1 ControlClick($hMsgPanel, "", "[NAME:cmdOK]") WinActivate($AppName) #cs MsgBox( 0, "test1", $idTSList) Local $idTSListCopy For $i = 0 to _GUICtrlListView_GetItemCount($idTSList) - 1\ #ce $idTSListCopy = _GUICtrlListView_GetItemTextString($idTestCaseList, $LoopCount) ExitLoop EndSwitch EndIf Return 1 EndFunc ;==>CheckError Problem is: i can't make this function (CheckError() ) return to main gui state, that means: break the If/ElseIf loop. The switch is working correctly (MsgBox on error shows only when it's activated). Checkerror() function works correctly - recognizes the error, stops script until decision is made. But it doesn't terminate If/ElseIf loop. Any help appreciated!
  2. Hey! Took me some time, but I've managed to find magical _PathSplit function That's how it looks right now, and is working properly Thanks for help! While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idAddTest Local $cFilepath Local $cFilename Local $cDrivepath Local $cDirpath Local $cExtension $sMessage = "Select test cases to load:" $sFileOpenDialog = FileOpenDialog($sMessage, @WorkingDir & "\data\tests\", "All (*.*)", $FD_FILEMUSTEXIST & $FD_MULTISELECT) If @error Then MsgBox($MB_SYSTEMMODAL, "", "No test(s) were selected.") FileChangeDir(@ScriptDir) Else FileChangeDir(@ScriptDir) $aFileList = StringSplit($sFileOpenDialog, "|", @CRLF) If $aFileList[0] = 1 Then _PathSplit($aFileList[1], $cDrivepath, $cDirpath, $cFilename, $cExtension) GUICtrlCreateListViewItem($cFilename & $cExtension, $idTestCaseList) ElseIf $aFilelist[0] >2 Then For $i = 2 to $aFileList[0] MsgBox( 0, "test", $aFileList[$i]) GUICtrlCreateListViewItem($aFileList[$i], $idTestCaseList) Next EndIf EndIf (...) EndSwitch WEnd
  3. Hello everyone! I've encountered a strange problem while adding files (or rather file names) to a ListView. Mechanics are simple: 1. Select files to add (FileOpenDialog + Multiselect) 2. Split selected string (filepath) into array (StringSplit) 3. File names appear on ListView (GUICtrlCreateListViewItem) Writing starts from second array (since 0 is array size, and 1 is filepath). Problem occurs when I try to add one file. Then, no filenames are added. As far as I know, selecting one file generates only 2 strings (0 and 1) to split, therefore no string is written into ListView. Is there any way / workaround to make this thing work properly? Some code here: While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idAddTest $sMessage = "Select test cases to load:" $sFileOpenDialog = FileOpenDialog($sMessage, @WorkingDir & "\data\tests\", "All (*.*)", $FD_FILEMUSTEXIST & $FD_MULTISELECT) If @error Then MsgBox($MB_SYSTEMMODAL, "", "No test(s) were selected.") FileChangeDir(@ScriptDir) Else FileChangeDir(@ScriptDir) $aFileList = StringSplit($sFileOpenDialog, "|", @CRLF) For $i = 2 to $aFileList[0] MsgBox( 0, "test", $aFileList[$i]) ;just for testing purposes GUICtrlCreateListViewItem($aFileList[$i], $idTestCaseList) Next EndIf EndSwitch WEnd And nothing more spectacular from ListView side: Global $idTestCaseList = GUICtrlCreateListView("List of Tests ", 24, 24, 225, 502, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) GUICtrlSetTip(-1, "List of test cases."& @CRLF &"Hold CTRL to select multiple lines.") Any help appreciated!
  4. Solution found via WinGetText and StringSplit, nevermind
  5. Hello again! I'm currently working on simple tool that will automate some of our internal application tests - store systems, to be precise What I'm trying to do, is send value from "Oczekiwana kwota" (that is 1 452,26 PLN in this example) into handler - to use it later on (see picture n.1). This value could vary depending on current sales, so it must be copied dynamically. Problem is: AutoIt recognizes only whole window and control (as you can see on the picture). Although! The desired value can be found under "Visible Text" (see picture n.2). I've tried to retrieve this data (and edit later on) via ControlGetText command, but it retrieves only first line of text Is there some way I can retrieve specific line of "Visible Text" into handler? Number of lines is always the same. Only values change.
  6. Ok it's working now I've wrote current program window into handler, changed it everywhere and fixed few "sleep" times - works fine now. It does actually check for errors. On every move / sum / enter, there's "CheckProduct" function - which actually works with every "warning" message box this program produce (same control class). So now it's perfect! Thanks alot!
  7. Hey! Just fixed this script as you did, but still it does jump over product 10200 and keeps filling invoice :/ And what do You mean by "test the returned result and depending further executing what's needed for this result"? Don't really follow You here
  8. Hello Everyone! I'm new here on forums and completely new into AutoIt language (although I have some VBA/C++ scripting behind me). I'm after few basic tutorials, studying examples, and my few own first scripts. We're currently looking for some simple test software, and I was ordered to look more into AutoIt (as it can become very useful in our regression tests), and just test its functionality. (FYI: it's POS software). I'm having problem with commands after exiting function. Here's the function that checks if the error occurs (in this case - wrong product number) - if it does, it asks for decision. Func CheckProduct() Local $Answer If ControlCommand("","","[CLASS:WindowsForms10.Window.8.app.0.21093c0_r12_ad1; NAME:panelMsgBox]", "IsEnabled", "") Then Sleep($Sleep_05) $Answer = MsgBox(52, "Error!", "Product not found. Continue testing?") Sleep($Sleep_05) Switch $Answer Case 6 MsgBox(0, "Error!", "Test will now continue.", 3) Send("{Enter}") WinActivate("TP.net POS") Return(0) Case 7 MsgBox(64, "Error", "Test canceled.", 5) Exit(0) EndSwitch EndIf EndFunc It's designed as a function - so we'll be able to use it every time after entering product number. After that, we have some examples of entering product numbers into the system. So after each "Enter" there's product-check function. ControlClick("TP.net POS", "", $ProductID) ControlSend("[CLASS:WindowsForms10.Window.8.app.0.21093c0_r12_ad1]", "", "[CLASS:WindowsForms10.EDIT.app.0.21093c0_r12_ad1]", "5") ControlClick("TP.net POS", "", $Multiply) Sleep($Sleep_075) ControlSend("[CLASS:WindowsForms10.Window.8.app.0.21093c0_r12_ad1]", "", "[CLASS:WindowsForms10.EDIT.app.0.21093c0_r12_ad1]", "10400") ControlClick("TP.net POS", "", $Enter) Call("CheckProduct") Sleep($Sleep_075) ControlSend("[CLASS:WindowsForms10.Window.8.app.0.21093c0_r12_ad1]", "", "[CLASS:WindowsForms10.EDIT.app.0.21093c0_r12_ad1]", "10") ControlClick("TP.net POS", "", $Enter) Call("CheckProduct") Sleep($Sleep_075) ControlSend("[CLASS:WindowsForms10.Window.8.app.0.21093c0_r12_ad1]", "", "[CLASS:WindowsForms10.EDIT.app.0.21093c0_r12_ad1]", "10200") ControlClick("TP.net POS", "", $Enter) Call("CheckProduct") Sleep($Sleep_075) Send("Company{Enter}") Send("IT{Enter}") Send("Country{Enter}") Send("Street{Enter}{Enter}") Sleep($Sleep_075) Product "10" doesn't exist in our database, so it'll trigger warning message. It works fine. Even function exit works properly. Although after selecting "Yes", the test continues, but it jumps over product "10200" and starts filling invoice (product 10200 requires invoice). Any idea why? I suppose it has simple explanation, though I couldn't find anything about this Thanks in advance!
×
×
  • Create New...