Jump to content

prunesquallor

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by prunesquallor

  1. There's an example in the Help file: WinWaitActive("[TITLE:My Window; CLASS:My Class; INSTANCE:2]", "") Presumably you can get the first and second instances into different handles, and then check for the window you want by looking for the extra button on the second one? Assuming you don't know which will be instance 1 and 2? ATB Prune.
  2. After testing I can confirm it works - many thanks. prune.
  3. Thanks for a tip - I'll give it a try! ATB Prune.
  4. This topic explains a problem I've been having for the last month. I'm trying to use AutoIt as an automated test system for our development work. I spotted a problem, so developed this script to test it: #cs ---------------------------------------------------------------------------- Tests the response of a TEdit Character map field to AutoIt. Toytown programming: no error handling. This version is GUILess. We need to do two things: 1. Put in lockout via BlockInput to stop effects of mouse moves and clicks. This needs #RequireAdmin. 2. Have the PauseMakeSureWindowIsReady routines to delay the write to and read from the control. #ce ---------------------------------------------------------------------------- #RequireAdmin Global $iLineCount = 0 ; Always updated by the OutputLogLine routine Global $iErrorCount = 0 ; Always updated by any test routine ;Open log file, write first line Global $fLogFile = FileOpen(@ScriptDir & "\TestCharMapLogFile.txt", 2) OutputLogLine("Started UAT Test Char Map at " & GetNow(), 1) ;Start test executable Run(@SystemDir & "\charmap.exe") Global $hWHandle = WinWaitActive("Character Map", "", 2) BlockInput(1) ;Run test xx times checking input into field For $iI = 1 To 10000 $sPasswordText1 = "ufVNn{{""" SendTextToControl($sPasswordText1) OutputLogLine("Password field given password =>" & $sPasswordText1 & "<=") CheckTextFromControl($sPasswordText1) OutputBlankLine() Next BlockInput(0) ;Write last line, close out log file OutputLogLine("Run completed at: " & GetNow() & " with " & $iErrorCount & " errors.") FileClose($fLogFile) Exit ;Send text string to control Func SendTextToControl(Const $sText) Local $iSendTextCharRaw = 1 PauseMakeSureWindowIsReady() ControlFocus("", "", "[CLASS:RICHEDIT50W; INSTANCE:1]") ControlSend("", "", "[CLASS:RICHEDIT50W; INSTANCE:1]", "{HOME}+{END}{DEL}") PauseMakeSureWindowIsReady() ControlSend("", "", "[CLASS:RICHEDIT50W; INSTANCE:1]", $sText, $iSendTextCharRaw) EndFunc ;Check that control has test text string Func CheckTextFromControl(Const $sText) PauseMakeSureWindowIsReady() Local $sCheckText = ControlGetText("", "", "[CLASS:RICHEDIT50W; INSTANCE:1]") If $sCheckText == $sText Then OutputLogLine("Text in " & "[CLASS:RICHEDIT50W; INSTANCE:1]" & " is =>" & $sCheckText & "<= and is correct.") Else OutputLogLine("Text in " & "[CLASS:RICHEDIT50W; INSTANCE:1]" & " is =>" & $sCheckText & "<= and is INCORRECT. +++ERROR+++") $iErrorCount += 1 EndIf EndFunc ;Make sure our windows's active with pause Func PauseMakeSureWindowIsReady() Do Sleep(500) Until WinActive("Character Map") EndFunc ;Output line to log file, with trailing blank lines if required Func OutputLogLine(Const $sOutLine, Const $iExLines = 0) $iLineCount += 1 $sOutput = StringFormat("%06u", $iLineCount) & " " & $sOutLine FileWriteLine($fLogFile, $sOutput) For $iCount = 1 To $iExLines FileWriteLine($fLogFile, @CRLF) Next EndFunc ;Output blank line to log file Func OutputBlankLine() FileWriteLine($fLogFile, @CRLF) EndFunc ;Get formatted date and time ISO 8601 Func GetNow() return @YEAR & "-" & @MON & "-" & @MDAY & "T" & @HOUR & ":" & @MIN & ":" & @SEC EndFunc Basically, the script does: 1. Opens a log file. 2. Brings up the character map (which has a field one can enter text in). 3. Blocks all input to stop inputs interfering. 4. Goes into a loop where it clears the field, fires a bit of text into it, and then reads it back. There are at least 500ms pauses between each step, and what's sent in and read back is logged. 5. Unblocks input. 6. Closes out the log file and exits. If I run the loop 10,000 times, almost always the input will match what's read. But maybe once or twice in the 10,000 times I get this in the log file: 000150 Password field given password =>ufVNn{{"<= 000151 Text in [CLASS:RICHEDIT50W; INSTANCE:1] is =>ufVNn[{2<= and is INCORRECT. +++ERROR+++ Note the actual string I'm using is ufVNn{{" - the "arrows" are delimiters in the log. In this example, one of the "{" has been cap-shifted to "[", and the final quote has been down-shifted to "2". The actual shifted characters can change, and the shift can be in either direction. The frequency this happens isn't high (and seems to be machine-dependent), but I'd say it averages a couple of times per 10,000. It would seem odd if it were timing, as 500ms pauses are a long time for an Intel Quad Core X9650 running at 3.7GHz which isn't doing anything else especially. Does anybody have any other ideas? This is a problem for us as running an automated test 10,000 times is by no means unusual. Thanks, Prune
  5. Thanks. I'm using the explicit Sleep statement to make sure there is a pause - there's something a bit odd going on and I want to make sure it's not a timing issue. I may be re-raising this as there may be a specific issue with ControlSend/ControlGetText. But it needs more testing. ATB Prune
  6. If I understand correctly, once your script enters: While 1=1 WinWait("InstallRite 2.5c","Are you sure you wan") Send("{ENTER}") WEnd the script will never leave the loop. If you only expect the popup once, you could try: WinWaitActive(("InstallRite 2.5c","Are you sure you wan") Send("{ENTER}") Once the script has answered, it can drop through and exit. ATB Prune
  7. Thanks Jaberwocky6669/Makaule. I'm now doing a WinWaitActive at the start, to ensure that the target program comes up, then before I do anything with the fields I do: ;Make sure our windows's active with pause Func PauseMakeSureWindowIsReady() Do Sleep(100) Until WinActive("Window Name") EndFunc This has very nearly solved all the problems: still under test. ATB Prune
  8. Thanks for the reply. This is to make sure that the test Window is ready for input I presume? Thanks - I'll give it a whirl. ATB Prune
  9. Answering myself, a lot of the problems go away if #RequireAdmin is added (under Vista)! Not all though, but the main errors caused by mouse and key clicks definitely go away. Prune.
  10. Running something similar under SciTE I get the following errors:
  11. I'm trying to see if I can use AutoIt as a way to automate the testing of executables, and am hitting a few problems. I am assuming that AutoIt should be rather good at this, so would appreciate any help. I've created a Codegear C++ executable called ATI1.exe, which contains exactly 1 TEdit Password (ie masked) field. It has no other controls, and actually does nothing: the field simply accepts whatever is typed into it. It resides in the same folder as the AutoIt script. I then want to test that I can read what I've put into a field, so the script: 1. Opens a log file. 2. Starts the executable. 3. Writes and then reads the same string 100 times into the field. 4. Closes the log file and exits. It actually leaves the executable running, but this is a cut-down example. The script: #cs ---------------------------------------------------------------------------- Tests the response of a TEdit Password field to AutoIT. Toytown programming: no error handling. Needs executable in same directory called AIT1.exe with a single TEdit password field. Window name of executable is "AutoItPassTest1" #ce ---------------------------------------------------------------------------- Global $iLineCount = 0 ; Always updated by the OutputLogLine routine Global $iErrorCount = 0 ; Always updated by any test routine ;Open log file, write first line Global $fLogFile = FileOpen(@ScriptDir & "\TestTEditLogFile.txt", 2) OutputLogLine("Started UAT Test TEdit at " & GetNow(), 1) ;Start test executable Run(@ScriptDir & "\AIT1.exe") Global $hWHandle = WinWaitActive("AutoItPassTest1", "", 2) BlockInput(1) ; Doesn't do much ;Run test 100 times checking input into field For $iI = 1 to 100 $sPasswordText1 = "ufVNn{{""" SendTextToControl($sPasswordText1) OutputLogLine("Password field given password: """ & $sPasswordText1) CheckTextFromControl($sPasswordText1) OutputBlankLine() Sleep(100) Next BlockInput(0) ;Write last line, close out log file OutputLogLine("Run completed at: " & GetNow() & " with "& $iErrorCount & " errors.") FileClose($fLogFile) Exit ;Send text string to control Func SendTextToControl(Const $sText) Local $iSendTextCharRaw = 1 ControlFocus("", "", "[CLASS:TEdit; INSTANCE:1]") ControlSend("", "", "[CLASS:TEdit; INSTANCE:1]", "{HOME}+{END}{DEL}") ControlSend("", "", "[CLASS:TEdit; INSTANCE:1]", $sText, $iSendTextCharRaw) EndFunc ;Check that control has test text string Func CheckTextFromControl(Const $sText) Local $sCheckText = ControlGetText("", "", "[CLASS:TEdit; INSTANCE:1]") If $sCheckText == $sText Then OutputLogLine("Text in " & "[CLASS:TEdit; INSTANCE:1]" & " is: " & $sCheckText & " - and is correct.") Else OutputLogLine("Text in " & "[CLASS:TEdit; INSTANCE:1]" & " is: " & $sCheckText & " - and is INCORRECT. +++ERROR+++") $iErrorCount += 1 EndIf EndFunc ;Output line to log file, with trailing blank lines if required Func OutputLogLine(Const $sOutLine, Const $iExLines = 0) $iLineCount += 1 $sOutput = StringFormat("%06u", $iLineCount) & " " & $sOutLine FileWriteLine($fLogFile, $sOutput) For $iCount = 1 To $iExLines FileWriteLine($fLogFile, @CRLF) Next EndFunc ;Output blank line to log file Func OutputBlankLine() FileWriteLine($fLogFile, @CRLF) EndFunc ;Get formatted date and time ISO 8601 Func GetNow() return @YEAR & "-" & @MON & "-" & @MDAY & "T" & @HOUR & ":" & @MIN & ":" & @SEC EndFunc On runnning, the input into the field will match what is read, as long as I don't click anywhere on the executable or switch windows to another window. The comparisons will fail in this case: generally, use of mouse or keyboard and changing windows focus interferes with the comparisons. BlockInput doesn't seem to work (?), and doesn't stop me switching away from the test program window to another window. I can't attach a working version of the executable due to the combination of Codegear code bloat and my upload quota! So I guess the question is: can I get AutoIt to completely lock out all inputs and stop all window switching while the test is running? I'm new at this, so all help gratefully received! Prune
×
×
  • Create New...