September 20, 2013

50% Off Software Test Automation eCourses

Filed under: Announcements,Automation,Testing — Marcus Tettmar @ 3:32 pm

Just a heads up that our friend Randy Rice is currently offering 50% off his most popular Software Test Automation eLearning courses.

So if you’re interested in learning about software test automation you can grab yourself a bargain until Midnight Tuesday. Randy’s got the info here.

July 3, 2013

From the Archives: How to Start Writing an Automation Script

Filed under: Automation — Marcus Tettmar @ 8:57 am

I’ve decided to go through the blog archives and find posts which are still useful today but might be a bit hidden away.

So to get started here’s a post from 2006 which offers some tips on getting started with writing your first automation script:

http://www.mjtnet.com/blog/2006/01/17/how-to-start-writing-an-automation-script/

May 25, 2013

Test Plan Automation 101 – Macro Scheduler Style

Filed under: Automation,General,Testing — Antonius @ 10:18 am

This is a guest post by Antonius Momac and Jana Krawiec, QA Automation Analysts at Triple Point Technology.

“If you don’t know where you’re going, any road will take you there”

– George Harrison

The main questions to ask when considering automated software testing are: “Where do I start?”  and “Where is it that I want to go?”  If you spend too much time on the wrong path, you’re either going to fail or overspend on time and resources.  Therefore it’s a good idea to get a clear picture of how information systems (applications under test) work.  I don’t mean at the low-level of zeros and ones that are crunched by the CPU, but rather where human meets machine.

The fundamental to any software process is that there are three main parts:

the Input (start), the process (main action), and the output (end) .  From the input, some data is taken and changed by the process which generates the output; i.e. modified data.

As an automation engineer, the choice of what part of the process to automate is yours. Automate as much or as little as you see fit.  Think about your particular situation and what makes sense.  Do you automate the setup?  Or is it better to automate the steps of the test plan (the driver/autopilot) and/or the verification?  Better yet, all three, or just one of them?

We started with a manual test plan and fully automated it.  Simply because the Macro Scheduler scripting language is flexible enough to support automation from all approaches. Automating the setup, the input, the process (say clicking on a button, or some mouse actions), as well as the verification of the output and reporting went smoothly.  We created small scripts that were managed from a master script.  A full and complex four hour test plan was built.  Everything worked great until we put it to the action testing a new build. We discovered that our GUI is in constant flux, which caused major changes to wreak havoc on our automated scripts.  Real time maintenance of scripts was required, thereby slowing down the entire testing process.  Ironically, this is the exact opposite of what test automation is all about.

In the end, full automation didn’t work for us. Less technical minded testers were not interested nor capable of learning how to debug a failing script.  Moreover, with the introduction of new features and constant GUI changes, our major focus during testing went to maintenance of our automation routines instead of finding bugs in the new release. Knowing that we picked the best possible software for automation allowed us to start looking for alternative approaches.  We decided to bypass the GUI interaction and focus on the verification process, since we never experienced issues with it.  Before long, we were getting through the testplan faster by manual GUI interaction combined with the verification process. It allowed us to test the application quickly, accurately and in depth.  Once we got the best of both worlds, we decided to develop a tool that would handle the verification with minimal setup.  With this tool anybody could set it up and get right into regression testing and finding bugs faster.  It allows us to integrate automation into new test plans very quickly.

Let’s analyze a test plan of 156 US-Letter size pages in length to get a better understanding.  The Majority of the test plan, 125 pages (82.6%), are dedicated to verification or what we call a checkpoint.  Further breakdown of those 125 pages revealed that there is 1 verification process is being repeated 50+ times consuming 108 pages. Manual verification is tedious and time consuming. Automating this one repetitive process eliminates 70%(108 pages) of the entire test plan in one shot.

Best of all removing, adding or updating automated routines proves to be an efficient process. No need to reconstruct or redesigning existing scripts and routines, saving us plenty of valuable time with minimal maintenance. Clearly, this is the road anybody wants to be on when it comes to automating your test plan.

So when you’re thinking about automating your test plan, consider these three rules of thumb:

  • What needs to be automated – Any fixed and repetitive processes where automation will save time, and ensure accuracy.  Big wins equal huge time saving with little code.

  • What can be automated – depends on the tool you’re using, since Macro Scheduler can be used to automate any process, be careful.  Automate, but automate wisely…  Your milage may vary.

  • What should never be automated – pieces that require excessive time and resources allocated disproportionately to the amount of time saved (mostly from maintenance point of view).  Maybe your test plan needs to be reworked.

Remember Bill Gates quote: “…automation applied to an efficient operation will magnify the efficiency. …automation applied to an inefficient operation will magnify the inefficiency.”

Contact the authors:

Antonius Momac Twitter handle: @MoMacAttack and remember “If you’re not creating TROUBLE, you’re not creating much!
Automation Diva Jana Krawiec Twitter handle: @krawiecjp

May 9, 2013

Video: Screen Capture and Email Script

Filed under: Automation,Scripting — Marcus Tettmar @ 1:01 pm

Dorian has just uploaded a video demonstrating his Screen Capture and Email script. Nice video, check it out:

April 17, 2013

Paste Into Object Without Using Keystrokes

Filed under: Automation,Scripting — Marcus Tettmar @ 11:03 am

Someone asked today how it might be possible to paste what is in the clipboard into an object using Macro Scheduler without having to use keystrokes.

It can be done by sending the WM_PASTE message using the SendMessage API function.

Here’s an example:

//Sending WM_PASTE to an object causes a clipboard paste, like sending CTRL-V

//constants - here we define the WM_PASTE constant
Let>WM_PASTE=770

//we need the handle of the object we want to send WM_PASTE to - 
// - as an example let's find the handle of Notepad's edit window
// - for this example make sure Notepad is running with empty document
// - so that the window title us "Untitled - Notepad".  Modify if needed

GetWindowHandle>Untitled - Notepad,hWndParent
FindObject>hWndParent,Edit,,1,hWnd,X1,Y1,X2,Y2,result

//now send WM_PASTE to it using SendMessage API
LibFunc>User32,SendMessageA,result,hWnd,WM_PASTE,0,0

The only benefit I can see with this is that it doesn’t require keyboard focus. In theory neither should ObjectSendKeys and a CTRL-V require keyboard focus. The latter is simpler so I’d tend towards using that. And there may be some applications that work at a higher level and actually expect to see CTRL-V or similar.

Never-the-less it’s a nice example of sending a Windows message and it may be useful for some. So here it is.

March 27, 2013

Getting Data From Excel Without Office Installed

Filed under: Automation,Scripting — Marcus Tettmar @ 11:00 am

In this post from 2008 I demonstrated how to get data from Excel worksheets using Macro Scheduler’s database functions.

This works fine if Office is already installed on the PC.   But what if you want to get data from an Excel sheet and the PC you are running on doesn’t have Office installed?

Well you need the Office Data Connectivity Components which you can download from microsoft.com here:

http://www.microsoft.com/en-us/download/details.aspx?id=23734

This will install the OLEDB/ODBC drivers which DBConnect can then use to make a connection to a workbook.  You can then use DBQuery to retrieve data from a sheet as shown previously.

January 24, 2013

How to tell if the current session is a Remote Desktop session

Filed under: Automation,Scripting — Marcus Tettmar @ 10:51 am

Here’s a small piece of code which will tell you whether the current session is a Remote Desktop/Terminal Services session or not:

Let>SM_REMOTESESSION=4096
LibFunc>User32,GetSystemMetrics,isRemote,SM_REMOTESESSION
If>isRemote>0
    MessageModal>Current Session is RDP/Terminal Services Session
Else
    MessageModal>Current Session is Local Session
Endif

December 7, 2012

Custom Event Triggers

Filed under: Automation,Scripting — Marcus Tettmar @ 10:11 am

Did you know you can make just about any kind of schedule or trigger using Custom Event Triggers?

You’ll find the custom trigger option under Macro Properties in the Trigger tab.

Parsnipnose3000 has just posted a tip on Custom Event Triggers to the forums, showing how you can have a macro fire based on an image appearing on the screen. Check it out.

October 30, 2012

Controlling Apps that Run as Admin

Filed under: Automation,Vista,Windows 7,Windows 8 — Marcus Tettmar @ 10:16 am

By now you are probably aware of UAC (User Account Control) that came along when Vista was released. And you probably know that to do anything like copy files to Windows\System32 or Program Files or do other administrative stuff you need to be running as Admin, or you’ll get the UAC prompt come up asking you for permission to continue. And when you continue the thing you launched is then running as admin.

For sensible reasons, Windows is designed so that an ordinary level process – i.e. an application that is running under a standard user account without administrative privileges (let’s call it an un-elevated application) is not allowed to manipulate, interact with or exchange information with an elevated process (one running with administrator privileges or “As Admin”).

Macro Scheduler runs “as invoker”. In other words it runs at the level of the user who starts it. In most cases, and by default, that means it is running without administrator privileges. Unless you have disabled UAC, or chosen to run Macro Scheduler as admin, or have set the Macro Scheduler shortcut properties to launch Macro Scheduler as admin, then Macro Scheduler will run as a standard user without administrative privileges.

Since a standard process is not allowed to manipulate an admin process, Macro Scheduler is not able, by default, to send keystrokes into windows belonging to processes running as admin.

Try it. Run Notepad as admin and then try the following simple macro in Macro Scheduler:

Setfocus>Untitled – Notepad
Send>Hello World

You’ll see nothing happen. The text “Hello world” will not arrive in Notepad.

Now close Notepad and run Notepad as normal and of course the script works.

So what do you do if you NEED to send keystrokes into an admin level window? Well, unless it is possible to run that process as an ordinary user you will need to also run Macro Scheduler as admin.

To run Macro Scheduler “elevated” as admin, right click on the Macro Scheduler shortcut and select “Run as Administrator”. If you have UAC enabled (the default) you’ll see the UAC confirmation box pop up to make sure you’re happy to continue. Ok that and now Macro Scheduler is running as admin.

Now try running Notepad as admin again and you’ll find our little macro works.

Some legacy applications written before Vista came along were developed assuming the user had administrative privileges, which was common in the days of XP. This was poor practice but widely done. A common transgression was that they would write their settings and files to the Program Folder. In order to run these applications under Vista or later they would therefore have to be run as Admin, unless there was any way to force them to write data to another more sensible location. Sadly there are still applications that do this, especially older ones that are no longer maintained. Since the only way to use such legacy apps on Vista/Win7/Win8 is to disable UAC or set them to run as admin and put up with the UAC prompt, if you need to automate them you’re going to have to also run Macro Scheduler (or your compiled macro) as admin.

Short version: If you wish to automate an elevated application (one that runs as admin), Macro Scheduler or your compiled macro, also needs to be running elevated.

October 29, 2012

My Most Used RegEx

Filed under: Automation,Scripting — Marcus Tettmar @ 10:33 am

It occurred to me the other day while working on a script for a customer that I use this regular expression frequently:

(?<=TOKEN1).*?(?=TOKEN2)

It is very useful when parsing information out of web pages, or when finding elements in web pages.

What it does is pull out all the text between TOKEN1 and TOKEN2. Those could be other pieces of text, or html characters, or whatever.

As an example, recently I wrote a script which loops through all rows in an HTML table, and pulls out an order number, then looks this order number up in an Excel sheet. The order number appeared in a table cell along with other information. It was the first item inside an <i> (italics) tag and was followed by a space and then a hyphen. So I used this to pull it out of the row:

RegEx>(?<=<i>).*?(?= -),this_row,0,matches,nm,0

See how it looks for everything between the ‘<i>’ and ‘ -‘ (space then hyphen).

The next thing my code needed to do was find the ID of the single input field in the same row. This input was used to enter the order quantity, obtained from the Excel sheet. The ID is not something we know up front but it’s the only input field in the row. So I did this:

RegEx>(?<=id=").*?(?="),theInput,0,matches,nm,0

In other words, pull the text between id=” and “, which gives us the input’s ID value. We can then use that later to identify and fill the input field.

Regular Expressions are daunting at first. But eventually you find a small number of patterns help in many situations. This is one that I often find useful.

What’s your oft-used regular expression?

« Newer PostsOlder Posts »