Friday 15 June 2012

Entry point in your Automation Framework

*getGlobalDataxlsPath()shall return the complete path of "GlobalData.xls" file

This is a small part to understand  getGlobalDataxlsPath()


Now the logic behind having an entry point for your Automation framework is whenever you execute any script, your framework structure should be available in Execution QTP environment. Since "GlobalData.xls" itself contain the structure, how you gonna access this excel sheet seamlessly.

One Idea, let's leverage QTP's Enviroment("TestDir") variable.

So your function called getGlobalDataxlsPath() Should return a path like for example 
"C:\\whereveryouhaveplaced\GlobalData.xls"
Colored path is what we need to extract.

Look at below code

Function  getGlobalDataxlsPath()
                 getGlobalDataxlsPath = Mid(Environment("TestDir"), 1, instr(1,Environment("TestDir"), "Framework")+10)
End Function

I hope you got dat!!!

Notice the dependency, your Framework Base folder should contain the word "Framework".

-Pankaj Dhapola
Let's Think on it

4 comments:

Raju Krish said...
This comment has been removed by the author.
Raju Krish said...

I think the person who is new to qtp or programming will find it difficult to understand..so please explain it more deeply so that it will help the freshers to understand..indeed great attempt..thanks for doing

Pankaj Dhapola said...

ummm, okay Raju.

Well Thx.

I see your point. I shall be arranging topics in sequential manner.
Don't go by name of function.
What this function do is returning path of your pillar data file.
When I say pillar which means your foundation of Automation framework.

Let's take an example of C language, void main() acts as entry point of you code execution, c compiler compiles the code and while running code, it find main method and line by line start executing instructions.

Like wise your to design a framework its a best practice to have benchmark where you can make sure your resources like library files, Test Data, scripts etc. are intact. So GlobalData.xls file provide that architecture in simple manner.
When we are talking about portability of your framework folder, your Framework folder could be placed anywhere in shared drive or your colleague's desktop. In a situation where you have developed a particular script and some resources are associated with scripts, when you try to run your script on colleague's pc, you will come across many configuration issues like path miss match, file not found etc.
To overcome all this you need to have a Single place which will provide paths of resources where they are placed, Now internal structure of framework folder is intact, but what about the base folder path, it will definitely changes right?

So this function will give me the base folder path plus GlobalData.xls file.

Raju Krish said...

Thanks a lot Pankaj...keep up the good work..:)