I am creating some automated test scripts to test a piece of software. Im doing this in a modular way so that I can more easily dictate which scripts are being and change this, while having all the scripts pre-compiled
I have a script which is launched with parameters from a batch, this opens up my compiled script which enters in the login details and presses OK to any dialogs that may appear. This part works as intended.
At the end of the script I am trying to re-gain focus onto the main application window, set the window to fullscreen and then run the next batch file to perform the next test etc.
in this example "$practice" refers to the main application's window title, which I have derived using the AutoItv3 Info tool.
WinWaitActive($practice)
$hWnd = WinGetHandle($practice)
; FullScreen
WinSetState($practice,"",#SW_RESTORE)
WinSetState($practice,"",#SW_MAXIMIZE)
RunWait(#ComSpec & " /c " & "TestStart.bat")
However, this is not regaining focus and maximising the window as expected, i think the applications splash screen could be interfering.
If I manually Click into any part of the application to focus on it, then the dialog will be set to fullscreen and then my second script will run.
What should I do to make this last part of the script behave as I wish?
WinActivate ( "title" [, "text"] ) - Activates (gives focus to) a window.
title - The title/hWnd/class of the window to activate. See Title
special definition.
text [optional] The text of the window to activate. Default is an
empty string. See Text special definition.
More info here.
This is how I ended up resolving the issue
WinActivate($practice)
WinWaitActive($practice)
$hWnd = WinGetHandle($practice)
ControlFocus($hWnd, "", "[CLASS:XTPToolBar; INSTANCE:1]")
; FullScreen
WinSetState($practice,"",#SW_RESTORE)
WinSetState($practice,"",#SW_MAXIMIZE)
RunWait(#ComSpec & " /c " & "sequence.bat")
By adding WinActivate and then manually giving control focus before calling WinSetState
Related
I want to find and click a button using Autoit. I tried AutoIt Window Information Tool but the button is not recognized so ControlClick() fails.
The button is active on the current window but Send("Enter") does not work. Tried using MouseClick() but the window does not appear in the same place every time, and I tried this script:
$hWnd = WinWait("vcredist_x86")
WinWaitActive("vcredist_x86")
ControlClick($hWnd, "", "[CLASS FROM AUTOITINFO]", "Left", 1)
but neither of them works. Is there any other way to identify and click the button?
If both version of AutoItWindowInfo(32 and 64bit) don't "see" the control you need to automate, here is what you can do:
Method 1 - Sending keystrokes:
Activate the window with WindowActivate
Send a number of TABs until the control is focused(if its not initially)
Send ENTER or SPACE
Method 2 - MouseClick:
Activate the window
Get the coordinates of a control relative to the application window(position the window at 0,0. Open Autoit Window Info, click on Mouse tab and get the position of the button). That position is usually always the same
When your code is running it must get the window position with WinGetPos and then add control position you got in step 2. That's your clicking position.
Method 3 - PixelSearch(If the control has unique color):
Get the desired color with AutoIt Window Info(mouse tab)
Search it using PixelSearch
Click the coords you got
Method 4 - ImageSearch:
Get ImageSearch UDF and DLL
Make a picture of the button
Search and click it
NOTE: Sometimes you need to give your script Admin rights in order to automate certain windows.
When AutoIt Window Information Tool failed me I had success using the text property of the button/ui control:
ControlClick($hwin, '', '[CLASS:Button; TEXT:Cancel]')
Experiment with "&" in front of one of the characters (underlined by Windows to indicate an Alt + key shortcut), so try "&Cancel" instead of "Cancel". If that fails try ControlFocus() first:
ControlFocus($hwin, '', '[CLASS:Button; TEXT:Cancel]')
ControlClick($hwin, '', '[CLASS:Button; TEXT:Cancel]')
Inspecting .exe files for GUI resources (using Resource Hacker for example) may expose text/properties of a control. Example:
Installed it like 1 hour ago, added some code and forms. Then wasted to test it out on browser with ctrl+F5 command and all I see is loading of the page.
http://pasteboard.co/1wumd89u.png
Reddit, what to do ._ .?
P.S: Tried to restart VS and change browsers. Did not helped.
I assume you are running the app via internal iis (casini). Using ctrl+F5 will run your app without any debugging support. Try using F5 only instead.
As christutty suggest put an early breakpoint. Select your Default.aspx file from the solution browser and hit F7, this will bring up the codebehind of your default page. You will see the page_load event, declare a variable like:
For C# string myString = "Hello World!;
For VB myString As String = "Hello World!"
On the left side of that line click untill you get a red dot. Red dots are break point, mean that the debugging will stop the page execution. After you hit F5 and get to that break point hit F10 for each subsequent line, hit F11 if you enter into an external method.
I'd like to compile and deploy a finished image that will efficiently display the image I've set up in the following line:
imgtag.ImageUrl = "..\..\Images\IMG_Temp\" & "PVATmp" & Trim(CStr(mlnk)) & ".jpg"
This line displays the image smoothly and quickly in the designer when I debug, but not after the program is compiled and displayed on an IIS Web server instance. For one thing, the image is displayed on a postback in designer, but that condition in the deployed version cannot show the image. I have to refresh the page.
Any ideas?
The path the image is displayed from is relative. ..\..Means you are moving 2 levels up from where you are now. "where you are now" likely means something different while debugging than it does when deployed.
Also, does your variable mlnk have a value?
Try to use like this:
imgtag.ImageUrl = Server.MapPath("~/Images/IMG_TEMP/PVATmp" + Trim(CStr(mlnk)) + ".jpg";
This is in case when you IMAGES folder is located in the root path
The felx builder (on eclipse) next/previous word command, usually bound to CTRL-RIGHTARROW on OPTION-RIGHTARROW on the mac, doesn't stop for ":" and "." and in a few other cases.
It's clearly a wrong behaviour for action script development!
How can I change it?
Here is the fix:
http://www.visible-form.com/blog/mac-eclipse-word-boundary-issue-fix/
"Go to System Preferences > Language & Text > Text, and set the ‘Word Break’ dropdown to ‘English, United States (Computer)’."
Remember Quit Flex Builder and restart it. If this doesn't work, try restarting the OS.
This option is missing in Mavericks… you can fix it with:
defaults write .GlobalPreferences AppleTextBreakLocale en_US_POSIX
Is there a way to close a pop up window after the page writes binary data (PDF) to the browswer?
Here are the details:
Whenever my web appilcation needs to print, it will pass some parameters over to a pop up window, which will display the print options. When the user clicks on the Print button, it will set the src of a iframe that will call the page that does the printing.
I have PDFConverter to convert URL / HTML to a pdf file. At the end of the converting, it will write the binary to the browser. Here are some code:
response.AddHeader("Content-Type", "binary/octet-stream");
response.AddHeader("Content-Disposition",
"inline; filename=" + fileName + ".pdf; size=" + pdfBytes.Length.ToString());
response.Flush();
response.BinaryWrite(pdfBytes);
response.Flush();
After this is done, i will need to close the pop up window. However it seems like you can't do anything after the response is flushed. Any ideas?
Thanks in advance!
Angela
Instead of creating the iframe in the popup window, you could create it in the parent window. This way once the user clicks the print button, you could safely close the popup without interupting the printing process. But instead of going through all the pain of creating new popups windows which might be blocked by some browsers, I would simply create some placeholder in the main page so that the user could choose printing options and then print the document.
Just in case anyone else is having the same problem. This is the solution that seems to work for me.
I use the jQuery Simple Modal to show my option list page. On this page, I have a window timer running every 1 second to check against the server if the print job is done. I use ajax for that. Once the job is done, I update the session variable, and the ajax call to the server will pick up the session value and close the pop up window.