When sending keystrokes to other applications remember that Macro Scheduler works much faster than a human being can type. Many applications do form field verification or background processing on the fly as the text is received. And most applications were designed on the assumption that a human being would be operating them. It may not have occurred to the developers that a robot might try to send a stream of text to the UI at the rate of 5000 characters a second!
With some applications if you try to send too many characters at once you may find that some of those characters fail to show up, or the string is truncated.
The solution should be obvious by now. That is to slow down the key send rate. You can do this easily by setting the SK_DELAY parameter which introduces a specified millisecond delay between each character.
Let>SK_DELAY=20 Send>long_string
Of course you could break the long string down into smaller chunks and insert a delay between them:
Send>part_1 Wait>0.3 Send>part_2 Wait>0.2 Send>part_3
But SK_DELAY is simpler and easier if you can’t control the length of the data easily.
A related issue I see every now and then is when “tabbing” from one field to another on a form. Pressing the tab key moves the focus to the next field, so we use this while sending data into a form. Sometimes we’ll encounter an application which needs a bit of time after a field has been focused before it can accept data, or the other way around. So sending Tab immediately after/before sending the data with no delay fails to work. Adding in a small delay between sending the data and the Tab solves it:
Send>field_data Wait>0.3 Press Tab Wait>0.3 Send>next_field Wait>0.3 Press Tab etc
Similarly when we need to tab through lots of fields at once without sending data we may try to save ourselves coding time by writing:
Press Tab * 10
But if the app needs time to react between each tab we may have to split that out into separate tabs with delays between them or replace with a repeat/until loop:
Let>tabs=0 Repeat>tabs Press Tab Wait>0.2 Let>tabs=tabs+1 Until>tabs=10
As I’ve said many times before the most common causes of things not working as expected are either timing or focus. Macros run way faster than a human can type which is often beneficial but if things aren’t quite right start off by slowing the macro down a bit. You can always speed it up later!
Macro Scheduler 12.0.6 is now available with the following fixes:
Workflow Designer and the SDK have also been updated to the same MacroScript version.
Registered Downloads/Upgrades | Evaluation Downloads | New License Sales
Rice Consulting have just announced that their new Practical Software Test Automation Course – which features Macro Scheduler for the scripting exercises – is now available in an e-Learning format.
This course focuses on the basics of software test automation and expands on those topics to learn some of the deeper issues of test automation. This course is not specific to any particular tool set but does include hands-on exercises using free and inexpensive test tools. The tool used for test automation exercises is Macro Scheduler.
The main objective of this course is to help you understand the landscape of software test automation and how to make test automation a reality in your organization. You will learn the top challenges of test automation and which approaches are the best ones for your situation, how to establish your own test automation organization, and how to design software with test automation in mind. You will also learn many of the lessons of test automation by performing exercises using sample test automation tools on sample applications.
I’ve been running through the course myself and so far I’m really impressed. This is a great way to get started on test automation and the great value e-Learning format means you can do it in your own time at your convenience. There’s also a whole module on using Macro Scheduler with some videos to help you get started.
You can see the course outline here, take a demo, or sign up on line here.
A quick and easy way to launch a URL in the default web browser is just to use the ExecuteFile command:
ExecuteFile>http://www.mjtnet.com/
However, I have recently discovered that ExecuteFile is currently limited to a command line length of MAX_PATH (260 chars) and that if more than 260 chars are passed it will cause Macro Scheduler to crash. This is a bug that we’ll get fixed in the next update (increase the limit if possible AND prevent a crash if more chars than can be handled are passed).
Another way to launch a URL in the default browser is to use the Run command. First you need to determine the path to the default browser which you can do by querying the registry:
Let>url=http://www.mjtnet.com/ //get path of default browser ... RegistryReadKey>HKEY_CLASSES_ROOT,htmlfile\shell\open\command,,browserEXE Run>%browserEXE% %url%
Macro Scheduler 12.0.5 is now available with the following fixes:
Workflow Designer and the SDK have also been updated to the same MacroScript version.
Registered Downloads/Upgrades | Evaluation Downloads | New License Sales
WebRecorder has been updated with a new version of the runtime component – IEAuto.DLL version 2.07.
This fixes a small bug preventing the ExtractTagByName function from extracting form field values. ExtractTag was working correctly but the same functionality to retrieve form field values was missing from ExtractTagByName.
Registered users can download the WebRecorder update from the registered downloads area.
Macro Scheduler 12.0.4 is now available with the following fixes:
Workflow Designer and the SDK have also been updated to the same MacroScript version.
Registered Downloads/Upgrades | Evaluation Downloads | New License Sales
I have a few scripts which perform actions on files. Rather than have the script ask me what file to use, it is easier to associate the file type with the script so that I can just double click on the file (or right click and choose “Open with”) in Windows Explorer.
For this to work the script must first accept a file on the command line. Here’s a really simple script which reads the content of a file passed into the script with the “thefile” command line parameter:
ReadFile>%thefile%,fdata MessageModal>fdata
If you were to compile this script and then pass thefile on the command line it would read in the file content and display it in a message box:
c:\path\myexe.exe /thefile=c:\somefile.mjt
Now, if we create a file association for .mjt files we would only need to double click on the .mjt file to have it open in the exe.
The easiest way to create a file association for a file that does not already have one is to just double click on the file in Windows Explorer. Then when asked choose to select from a list of installed programs and on the next dialog click on the “Browse” button to locate your executable.
If the file extension is already associated with other applications then right click on the file and choose “Open With” and then “Choose program…”, then UNCHECK “Always use the selected program to open this kind of file” and click on “Browse” to locate your executable.
Initially this won’t quite work. We need to make a small change, as this creates a mapping in the registry which looks like this:
“c:\path\myexe.exe” “%1″
We want to change it to:
“c:\path\myexe.exe” /thefile=”%1″
So after creating the file association via Windows Explorer we need to make a small registry change:
1. Fire up RegEdit.exe (Start/Run and then type regedit.exe)
2. Open HKEY_CLASSES_ROOT
3. Search for your exe name to find the “c:\path\myexe.exe” “%1″ entry
4. Make the change as above, changing the “%1″ to /thefile=”%1″
Now, when you double click the file (or right click/Open with) it will launch your exe, with the filename passed to it in the “thefile” parameter.
You could actually code the script in such a way that you don’t need to do the registry change. You could parse the COMMAND_LINE system variable to get the file from the command line, without requiring a custom parameter name. This is discussed in this forum post which talks about being able to drag and drop a file onto a script.
If you want to create the file association programmatically, take a look at what registry entries are created by Windows when you do it manually. Then you can use the registry functions to achieve the same. E.g. this script associates .why files with the “c:\where\why.exe” executable expecting the file in a parameter called “thefile”:
RegistryWriteKey>HKEY_CLASSES_ROOT,.why,,why_auto_file RegistryWriteKey>HKEY_CLASSES_ROOT,why_auto_file\shell\open\command,,"c:\where\why.exe" /thefile="%1"
Macro Scheduler 12.0.2 is now available with the following fixes:
Workflow Designer and the SDK have also been updated to the same MacroScript version.
Registered Downloads/Upgrades | Evaluation Downloads | New License Sales