0 Shares 542 Views 1 Comments

Saving already Opened Excel Sheet

May 17, 2013
542 Views 1

Saving already Opened Excel SheetSometimes some automation scenario looks very simple to automate, but it shows up its intricacy when you actually start working on it. Such things usually happens at the time when you do the POC (proof of concept) of an application. The objects and the high level scenarios looks ok to automate and you estimate accordingly, but at the time of the actual scripting you get hard time to achieve the required.

In this post I am going to explain one of these kind of challenges which I experienced in one of the project. To start with, I will first explain the scenario. Saving already Opened Excel Sheet –  Lets say you have an application, which shows a large number of tabular data for a particular query on UI. These data needs to be retrieved into an excel file. You have an ‘Export to Excel’ functionality available on the UI, which exports all the data into an excel file and the file opens up at your screen. The requirement here is the opened excel  file needs to be saved at specific location for further references.

The first part that is to click on ‘export to excel’ button can be easily done by capturing the object and performing action on that Export to Excelobject. But the actual problem is with saving the opened excel. To tackle this problem,I tried various methods, and end up with few ways to do the same. Here I am explaining the two best and easy approaches.

In first approach,[sociallocker] I captured the excel object and stored it in the object repository.I captured the object because I need to set the focus on the excel.This will help me to perform the set of keystrokes for saving the Excel.Sequence of keystroke for saving the excel is as follows :

As soon as I press “X” or “9” ,Save As dialog box appears, where we need to set the path and click on Save button.

For stimulating the sequence of keystrokes in QTP, I used the “Sendkey” method. For using this method we need to create an object of “WScript.Shell” first.

Now I will use the SendKey method to perform the keystroke in an sequential order

After use of the Wshell object we should set the value of it as nothing.

The second approach is one of the best approach I had came across to encounter this excel problem.In this we used “GetObject” function returns a reference to an object provided by a COM component.In our   case “GetObject” check whether any Excel object is present or not , and if present then save it as per the path mention by us.

Syntax

where

object : WScript object.
Pathname: The fully qualified path name of the file that contains the object persisted to disk.
ProgID: (Optional) The object’s program identifier (ProgID)
Prefix: (Optional) Used when you want to sync the object’s events. If you supply the Prefix argument, WSH connects the object’s outgoing interface to the script file after creating the object.

[/sociallocker]

If you also have such situation, where you find difficulties to automate or need help on any other similar issues, please feel to reach as by this contact form,we will get back to you as soon as possible.

Till then

Happy Learning!!!

You may be interested

Setting up Mobile Automation Project in Windows
Katalon Studio
77 views
Katalon Studio
77 views

Setting up Mobile Automation Project in Windows

Saket - Sep 20, 2017

This tutorial explains how to setup a mobile automation project and test a mobile app using Katalon Studio on Windows. This tutorial assumes that you are familiar…

Katalon Studio GUI Overview
Katalon Studio
147 views2
Katalon Studio
147 views2

Katalon Studio GUI Overview

Saket - Sep 14, 2017

GUI Overview After installing and setting up Katalon Studio for your automated test, you must understand the GUI. In this post we will walk you through the…

LeanFT Tutorial #4: Application Model Overview
LeanFT
124 views1
LeanFT
124 views1

LeanFT Tutorial #4: Application Model Overview

Saket - Sep 10, 2017

In this post we are going to focus on Application Model in LeanFT. Refer our earlier posts on LeanFT Getting Ready with LeanFT Browser Extensions and Settings…

One Comment

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...