MuazIbrahim Posted April 26, 2021 Share Posted April 26, 2021 Hi Guys, i'm new in AutoIt and really would appreciate your help im doing an automated smoke test, the test is simple : running exe - check if window active - take screenshot and write log if test passed or failed here is my script Quote #include <File.au3> #include <ScreenCapture.au3> Func _WinWaitActivate($title,$text,$timeout=0) WinWait($title,$text,$timeout) If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc Local $sMyTestLog = "C:\Autoit Logs\" &"TestOpenChrome" & @Year & "-" & @MON & "-" & @MDAY & ".log" Func TestOpenChrome() Run('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe') if WinExists("Neuer Tab - Google Chrome","") Then _WinWaitActivate("Neuer Tab - Google Chrome","") WinSetState("Neuer Tab - Google Chrome", "", @SW_MAXIMIZE) _ScreenCapture_CaptureWnd($sMyTestLog & "_Image.jpg", "Neuer Tab - Google Chrome") MouseClick("left",1514,17) _FileWriteLog($sMyTestLog,"Test 1 - Passed - ") Else Sleep(2000) _FileWriteLog($sMyTestLog,"TestOpenChrome - FAILED " & "Failure reason ?") _ScreenCapture_Capture($sMyTestLog & "_Image.jpg") EndIf EndFunc Call ("TestOpenChrome") now the problem i'm facing that the Else(false) branch is always being executed even if the true condition was the case , am i missing something here? another question, is there a better or more effieicent way for the verification here? Thank you in a Advance Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 26, 2021 Moderators Share Posted April 26, 2021 Moved to the appropriate forum. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Nine Posted April 26, 2021 Share Posted April 26, 2021 (edited) 1. When you post code, please use this tool. 2. You should not mix functions and main code in alternation, it makes the code very hard to follow. Put your main code together at the beginning of the script (best practices). 3. As for your problem, it seems that you should put a sleep after run to let time for the program to load. Edited April 26, 2021 by Nine MuazIbrahim 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
MuazIbrahim Posted April 26, 2021 Author Share Posted April 26, 2021 1 hour ago, Nine said: 1. When you post code, please use this tool. 2. You should not mix functions and main code in alternation, it makes the code very hard to follow. Put your main code together at the beginning of the script (best practices). 3. As for your problem, it seems that you should put a sleep after run to let time for the program to load. yes the sleep solve the problem Thank you and i will take care of the script structure as per your notes 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