Automating a N languages website using single QTP Script – The Realtime usage of Repository Collection Object

You might face a situation during automation where you given a website which can be accessed in say 10 different languages. Now the question that arises here is how should you proceed to automate it. Many of us would think to create 10 different scripts for each language isn’t it..!! :).
But the same can be implemented using one script only. How.? See below for details:
QTP provides collection object called Repository Collection that enables you to programmatically associate or attach the Object Repository dynamically at run-time during test run. So to automate the website in different languages, we can simply create 10 object repositories and associate them either one by one or one Iteration of test run.
We can parametrize the object-repositories path either through Data-Table or using files etc and test the application easily. i.e.
Parameterzing Object Repository Path
One way to do is adding all the object repositories paths into datatable as shown below.
repos_Path = DataTable.Value("Repo_Path","Global")

Associating Object Repository
The Add method is used to add an object repository file to the specified index position in the run-time collection of shared object repository files associated with the current action.

RepositoriesCollection.Add(repos_Path)

Complete Script
''===========================================================================
'Get Total Number of Shared Repositories Associated with the current action
x = RepositoriesCollection.Count
Print "Total Repositories Associated With " & Environment("ActionName") & " = " & x
'Checkpoint to Add/Associate Shared Repositories if no repos is associated
If x = 0 Then
'Parameterizing Repository Path
repos_Path = DataTable.Value("Repo_Path","Global")
'Associating OR
RepositoriesCollection.Add repos_Path
End If

‘Get Total Updated Number of Shared Repositories Associated with the current action
x = RepositoriesCollection.Count
Print x
”===========================================================================

Advertisements
By shalabhdixit

2 comments on “Automating a N languages website using single QTP Script – The Realtime usage of Repository Collection Object

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s