0 Shares 923 Views 2 Comments

Update Single Result File from Multiple Scripts Simultaneously

Jun 10, 2014
923 Views 2

ExcelLockedMost of the time, the automation suite needs to create result in excel format for easier portability. It’s a general practice that is being followed usually, that an automation suite when being executed on a machine it creates its own result file. The same suite when gets executed on multiple machines with different test sets creates multiple result files separately.  which needs to be consolidated at a later point and consumes extra effort.

As we are into automation, its in our blood to have all the things automated and ready with a single click, isn’t it? I generally don’t recommend/want to put efforts in such activities and always try to automate even its a very simple process to do manually. But only if it saves your time 🙂

The main problem here, is  to update the excel result file for a script when it tries to open the file while another script is already working on the same file. QTP/UFT/TestComplete or perhaps any other tool does not have any mechanism or built-in method to check whether the file is currently being edited by another test to prevent overwriting and errors. This is the reason, why we cannot use a single result file to be updated from several scripts simultaneously. However this can be achieved using Excel Object Model.

Excel object model has various properties and methods. There is one property as ‘Read Only’ which can be used here and should do the trick. Refer to MSDN – Microsoft Excel Object Model for overview and complete list of Excel Object Model methods and properties. Find more details about Read Only property of ExcelWorkBook here.

WorkBook.ReadOnly : Returns True if the object has been opened as read-only. Read-only Boolean.

To use this property, you will need to create an object for excel application. Using this object, you can try to open the desired excel workbook. Retrieve the readonly property and if its readonly, then close the file. Continue the same process until the file is available to edit.

Checkout the sample code below

The following example will loop until the file is not read-only (opened by another script). Within the loop, the file is opened and then the ReadOnly property is retrieved. If the file is read-only, the file is closed and released. The script will wait for a short time, then attempt to open the file again.

Implementing this piece of statements in your code, where you open your file to update, should solve the purpose. Hope this will certainly help in your automation.

You may be interested

UFT Patch Updates – UFT 14.03
Unified Functional Testing
1861 views1
Unified Functional Testing
1861 views1

UFT Patch Updates – UFT 14.03

Saket - Mar 11, 2018

Post the launch of UFT 14.0, there are three patch updates has been released including a number of features and enhancement. Recently Micro Focus unveiled third patch…

Setting up Web Service Automation Project
Katalon Studio
1446 views
Katalon Studio
1446 views

Setting up Web Service Automation Project

Saket - Oct 24, 2017

Web services are specific services that can be published and called over the Internet by client applications. Katalon Studio supports functional testing of web services. This topic…

Setting up Mobile Automation Project in MacOS
Katalon Studio
1169 views1
Katalon Studio
1169 views1

Setting up Mobile Automation Project in MacOS

Saket - Oct 09, 2017

Using Katalon Studio, mobile tester can design automation test for both Android and iOS to run on physical devices, cloud services and emulators. This tutorial explains how…

2 Comments

  1. Got a chance to work under Saket’s leadership. He is super talented and had answers for all the issues I raised. Best thing i learned from him is Learning how to learn. Best luck!

    Reply

Leave a Comment

Your email address will not be published.

Most from this category

Join The Growing Group of 15000+ Test Automation Engineers

Signup for our newsletter and get access to free downloads, as well as tips, tricks and techniques and various test automation resources.
Name
Email Address
Secure and Spam free...