Jump to content

Doing Simple Smoke Test - Need Help - (Moved)


Recommended Posts

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

  • Moderators

Moved to the appropriate forum.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 by Nine
Link to comment
Share on other sites

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...