Results for QTP

How To Bypass SSO in Automation Testing?

July 05, 2017
SSO stands for Single sign on. The browser may ask for user credentials or may take from windows authentication process. Due to same origin policy , it will never ask for user id and password as long as the user logs in the system. SSO is to prevent unauthorized access from client machine to the server resources.This is due to the solution of multi password issue. But during testing the we need to log, in the same client machine with multiple user credentials as if the real users are working. If the application is SSO enabled, it is not  possible as it will always take the original logged in user credentials for opening the application and never switch the profiles. In automation it is a real road block.

The simple SSO workflow is depicted below:

In RSA community as per doc 72967, they have proposed a solution - that is to pass SSO login as false in the url itself.
The link will look like-http://url?SSOlogin=false
unfortunately that solution did not work for us.
on further googling I found one more solution i.e to give username and password in the URL itself. Something like- http://myUserName:myUserPassword@url

The selenium implementation we tried as follows:
WebDriver driver=New FirefoxDriver();
String url="http://"+myUserName+":"+"myUserPassword"+"@"+url;
driver.get(url);
This solution did not also worked. Application keeps logging with old user name

A possible great work around would be to disable the SSO for testing URL. But, for our case, it was not possible. Also it opens up another kind of threats.Not a good solution.




In IBM forum , I have checked , on topic that says "Can I bypass single-signon using batch file or executable file?" The exact problem we were having!!!
The solution given:

  1. Login with test user log in credential in client box
  2. Disable integrated windows authentication[Tools-->Internet Options-->Advanced tab->clear the enable integrated windows Authentication(need to restart the IE)]
  3. Start the IE session as different user like in command prompt use runas command:
  • Open command prompt and navigate IE directory
  • give command runas/user:myUserName@fully_qualified_domain_name iexplore
  • When it prompts for password , provide password

Unfortunately, win-7 on wards this feature is not available. It will ask for password and never accept the password.As a result, we could not operate the same.

I got few more spicework.com-

  • Deploy a policy that sets the execution policy to remote signing.
  • make a .bat file that will open powershell and run command
They were also not effective as we really could not change the policy on login as a admin to use different switch.Also this will not work in highly secured zones. 

SQA forum suggested one solution..
1. go to IE-->Tools-->Options-->Advanced-->Uncheck the enabled Integrated  windows authentication under security. It is good to try but did not work for me.


One solution given in technibble to use utiman also did not suffice our requirements.Moreover runas command needs admin privilege to run.

The next possible  solution we have tested is powershell explained in denkingdom.com
@Echo off
SET this_script_directory=%~dpo
SET powershellScriptpath=%this_script_directory% mypoweshell.ps1
powershell_NoProfile_ExecutionPolicy.Bypass_command "&{start_processPowershell_argumentlist"
-NoProfilee -ExecutionPolicy ByPass -File ""%powershellScriptpath%""'-verb.RunAs}"


Another solution is to deploy a logout button having the following features:

  • Logout button should invoke the logout function which destroys all session tokens or render them unusable.
  • Server performs proper check for session check,dishonor any access/request from previous token.
  • A time out feature to logout client from server.




Developers were little hesitant to implement a new button as it was never told in the requirement itself.
While googling on SSO, I came to know it is something to do with Cookies. Once Cookies are getting destroyed, application can return to login screen.But at this point of time our objective was to implement something that can destroy the cookies. To bypass this by using a different log in, we need to reset browser cookie info from browser cookie storage area.
java implementation of deleting cookie:
public void deleteAllCookies()
{
driver.manage().deleteAllCookies();
}
set  allCookies=driver.manage().getCookies();
for (Cookie cookie:allCookies)
{
driver.manage().deleteCookieNamed(cookie.getName());
}


Now we can create a set of user cookies-

Cookies myCookie=new Cookie("myTestCookie","123456789123");
driver.manage().addCookie(myCookie);

to work with the cookie

driver.manage().getCookieNamed(myCookie);
A better approach could be:
Cookies myCookie=new Cookie("name","value")
                 .domain("your domain")
                 .expiresOn(new Date(2017,10,15))
                 .isHttpOnly(true)
                 .isSecure(false)
                 .path("/your path")
                 .build();
driver.manage().addCookie(myCookie);

Deleting Cookies from chrome is different, what we have implemented:
Browser("myUrl").highlight
Set oDelCookies=CreateObject("Wscript.Shell")
oDelCookies.sendkeys"^+{DELETE}"
wait 2
oDelCookies.sendKeys "Enter"
set oDelCookies=nothing
for IE the code to delete the same:

webUtil.DeleteCookies
A better approach could be as follows: This is from stackoverflow here
systemUtil.run "iexplore"
wait 2
clearAllDetails
wait 2
systemUtil.CloseProcessByName("iExplore.exe")

Function clearAllDetails

Dim oShell,oExec
Set oShell = CreateObject("WScript.Shell")
oShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1" 'clearing History
oShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2" 'clearing Cookie
oShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8" 'clearing Temporary Internet Files
oShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16" 'clearing form data
oShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32" 'clearing password
oShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255" 'clearing All
oShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351" 'clearing everything used in addons
End Function





Clear all chrome stored info via VBS:
set objFSO=CreateObject("Scripting.FilesystemObject")
strAppDataFolder=AQEnvironment.GetEnvironmentVariable("LocalAppData")&
"\Google\Chrome\User Data\Default"
set filesInFolder=objFSO.getFolder(strAppDataFolder).Files
set foldersInFolder=objFSO.getFolder(strAppDataFolder).subFolders
for each folder in foldersInFolder
if not ucase(Folder.Name)="EXTENSIONS" and not ucase(folder.name)="EXTENSION STATE" then
folder.delete true
end if
next
for each File in filesInFolder
if not ucase(File.Name)="PREFERENCES" then
File.delete
End if
next

Cleared all Firefox cache/password/cookies in VBS


set objFSO=CreateObject("Scripting.FilesystemObject")
strAppDataFolder=AQEnvironment.GetEnvironmentVariable("LocalAppData")&
"\Mozzila\Firefox\profiles"
strRomingAppData=AQEnvironment.GetEnvironmentVariable("AppData")&
"\Mozzila\Firefox\profiles"
set filesInFolder=objFSO.getFolder(strAppDataFolder).Files
set foldersInFolder=objFSO.getFolder(strAppDataFolder).subFolders
for each folder in foldersInFolder
folder.delete true
next
set foldersInFolder=objFSO.getFolder(strRomingAppData).subFolders
for each folder in foldersInFolder
set filesInFolder=folder.Files
for each File in filesInFolder
if (1,File.Name,"sqlite")>0 then
File.delete
End if
next
next
Now We got how to handle Chrome,IE and Firefox in order to delete cache.. It is time to integrate the same code with Java and call as a first step from our script

public void ClearAll() throws InterruptedException
{
try{
Runtime.getRuntime.exec("Path of the VBS");
}
catch(Exceptipon e)
{
e.printstackTrace();
}

}
For salesforce -Rajesh Ramachandra has described a process that is instead of providing http://xyz.salesforce.com provide http://xyz.salesforce.com?login. It will navigate to the login page instead of SSO login.



image credit:https://www.itcompany.com.au
How To Bypass SSO in Automation Testing? How To Bypass SSO in Automation Testing? Reviewed by Animesh Chatterjee on July 05, 2017 Rating: 5

How To Work With Automation Object Model In UFT?

May 25, 2017
AOM stands for Automation Object Model. This is an way to use UFT/QTP  and its resources . By this approach we can control the QTP from a separate program like-a VBS,macro. This is accomplished using  COM interface.that gives a freedom to access the all most 90% of the components of the software. Based on COM , AOM can communicate with the components.(access different methods,properties,object). It provides a set of controls, methods to help a developer/automation tester to execute script without touching UFT. It is externally useful while triggering batchrun from Jenkins or making an one click automation.

What is proper use case

  • This is useful when we want to change the QTP /UFT options during run time
  • Want to control UFT/QTP from our other application
  • Want to do some repetitive task in a regular interval
  • Migrating to continuous integration
  • Want to schedule scripts in a machine.
AOM is the better solution for the above uses. It uses COM (Component Object Model)- In the below section, we will see how to create an object of UFT application and work with different components of it.
There are three popular ways to create object of quick test-
Visual Basic Way:
Dim qtApp as QuickTest.Application
set qtApp=New QuickTest.Application
VBScript way:
Dim qtApp
set qtApp=CreateObject("QuickTest.Application")
Java Script way
var qtApp=new ActiveXObject("QuickTest.Application")
You can choose any one.But in this blog I am going to take Vb scripting:
Basic Settings
Dim qtApp
set qtApp=CreateObject("QuickTest.Application")
qtApp.Launch  ' launch QTP/UFT
qtApp.Activateview "Expertview" 'Open Expert View can be "keyWordView"
qtApp.showPaneScreen "ActiveScreen",True 'show the Active Screen can also be set 
'as "Debugviewer",True or "DataTable" False
qtApp.WindowState="Maximized" 'Maximize the UFT,can aslo be set as "Minimized"
qtApp.Test.Settings.web.BrowserNavigationTimeOut=50000
qtApp.Test.Settings.web.ActiveScreenAccess.userName="myUserName"
qtApp.Test.Settings.web.ActiveScreenAccess.password="password"

Run Options
qtApp.options.run.ImageCaptureForTestResult="onError"
qtApp.options.run.RunMode="Fast" can be set to Normal or slow based on the network speed
qtApp.options.run.viewResult=False ' can be true if you want the qtp result to display 
'after a run
qtApp.Test.Settings.Run.ObjectSyncTimeOut=100000
qtApp.Test.Settings.Run.DisableSmartIdentification=false 'can be true
Run Settings
This can be achieved in two ways ...

  1. Either you follow the hierarchy
  2. Or create an object of the test module

set qtTest=qtApp.Test
qtTest.settings.run.IterationMode="AllIterations" ' can be rngIterations or rngAll
'to run from iteration x to iteration y
qtTest.settings.run.startIteration=1
qtTest.settings.run.EndIteration=3
qtTest.settings.run.onError="NextStep" 'can be stopped by passing "Stop"
' or we can show error dialog by passing "Dialog"
Result Settings
Dim qtResultOpt
set qtResultOpt=CreateObject("quickTest.Run ResultsOptions")
qtResultOpt.ResultLocation="C:\testpath\Result\"
qtTest.Run qtResultOpt

if you move all result to a file:
const forReading=1
const forWritting=2
dim fso,f,result
set fso=CreateObject("scripting.FileSystemObject")
set f=fso.openTextfile("c:\test\result.txt",forWritting,True)
'you can create the text file by using fso
set qtResultOpt=CreateObject("quickTest.Run ResultsOptions")
qtResultOpt.ResultLocation="C:\testpath\Result\"
qtTest.Run qtResultOpt
result=qtTest.LastRunresults.Status
f.write("test1:Name of the test")
f.write(result)
f.writeBlankLines(1)
'close f,set objects to null if you have no further use
Library Settings
dim qtlibs
qtlibs=qtApp.Test.Settings.Resolurces.libraries
'to remove all
qtLibs.removeAll
Add a library:
If qtLibs.find("path of the lib"\abc.vbs")=-1 then
qtlibs.Add "path of the lib"\abc.vbs",1
End If
qtApp.Test.Save ' in this case you have to open the test in edit mode,readonly false

Repository Settings
set qtRepositories=qtApp.Test.Action("Action Name").ObjectRepositories ' for which the 
'repository needs to be added
If qtRepositories.find("path of the lib"\abc.tsr")=-1 then
qtRepositories.Add "path of the lib"\abc.tsr",1
End If
Environment Variable Settings
qtApp.Test.Environment.value("userName")="myUserName"
qtApp.Test.Environment.value("password")="password"
Action Settings
qtApp.Test.Actions.Count 'return the actions present in the test
qtApp.Test.Actions("Name of the action like 'Action1'").Description
'returns the description
qtApp.Test.Actions("Name of the action like 'Action1'").Name
'returns the name
'run a particular action by index
qtApp.Test.Actions(index as 1/2).Run
or
setqtTest=qtApp.Test.Action(index)
RunAction "Action2",oneIteration 'can be multiple iterations by providing the iteration number
Recovery Settings
'removing all recovery
set qtTestRecovery=qtApp.Test.Settings.Recovery
If qtTestRecovery.count>0 then
qtTestRecovery.RemoveAll
End If
'add recovery
qtTestRecovery.Add "path of the recovery file","Name of the recovery",1,"description"

'enabling the recovery:
For intIndex=1 to qtTestRecovery.count
qtTestRecovery.item(intIndex).Enabled=True
Next
or
qtTestRecovery.Enabled=true
'specify when to activate
qtTestRecovery.setActivationMode="onError"
Datatable Settings
qtApp.Test.Settings.Resources.DataTablePath="Path of your data table"
Log tracking Settings
with qtApp.Test.Settings.LogTracking
.Includeinresult=False
.port=18081
.IP="127.0.0.1"
.MinTriggerLevel="Error"
.EnableAutoConfig=False
.RecoverConfigAfterRun=False
.configFile=""
.MinConfigLevel="Warn"
End With
There are two launcher available out of the box.

  1. Web Application
  2. Window Application

Web launcher Settings
qtApp.Test.Settings.Launcher("Web").Activate=true 'can be false
qtApp.Test.Settings.Browser="IE", Can be chrome,firefox if supports
qtApp.Test.Settings.Address="www.google.com"
qtApp.Test.Settings.CloseOnExit=true

Windows Application launcher Settings
qtApp.Test.Settings.Launcher("Window Application").Activate=true 'can be false
qtApp.Test.Settings.Applications.RemoveAll 'removes all pre loaded Applications
qtApp.Test.Settings.RecordOnQTDescendant="False" 'record settings
qtApp.Test.Settings.RecordOnSpecifiedApplications=True


Addins Settings
arrAddins=qtApp.GetAssociatedAddinsForTest("Test path and Test Name")
'check if loading is successful
blnAddinRequired=False
For Each testAddin in arrAddins
If (qtApp.Addins(testAddin)).status <> "Active" then
blnAddinRequired=True
Exit for
End if
Next
'if change in the loaded addins is necessary
If blnAddinRequired Then
Dim blnActivateOk
blnActivateOk=qtApp.SetActiveAddins(arrAddins,error description)
If Not blnActivateOk Then
WScript.quit
End if
End if 
Set Parameters
To work with these, we need to create these parameters in QTP first.
Set pDefcoll=qtApp.Test.ParameterDefination
Set qtpParam=pDefcoll.GetParameters()
on Error Resume Next
qtpParam.Item("UserName").value="myUserName"
qtpParam.Item("Password").value="myPassword"
How to save Test
If qtApp.Test.IsNew Then
qtApp.Test.SaveAs "path of the script and Script Name"
Else
qtApp.Test.Save
End If
How to Connect To ALM/QC
qtApp.TDConnections.Connect "QCURL","Domain","Project Name","UserName","Password",false
How to Run a Test from ALM/QC
qtApp.TDConnections.Connect "QCURL","Domain","Project Name","UserName","Password",false
If qtApp.TDConnection.IsConnected Then
qtApp.Open [QualityCentre]Subject\path\script Name,False
qtApp.Test.Run
qtApp.TDConnections.Disconnect
How to Log a bug in ALM/QC
Here is complete guide of the code: http://www.ufthelp.com/2014/09/how-to-log-bug-in-alm-using-ota.html Here is a small different way to do:
Dim qcApp
 Dim BugFact,NewBug
 
 Set qcApp = CreateObject("TDApiOle80.TDConnection")
 'Intilizing the QC connection
 qcApp.InitConnectionEx "https://alm.com/qcbin"
 'Verifying User is connected
 If qcApp.Connected Then
  Print "User Connected to ALM Server"
 Else
  Print "User is not Connected to ALM Server"
  Exit Function 
 End If
 'Filling the UserName and Password for ALM
 qcApp.Login sUName,sPwd
 'Verifying User is Logged into ALM
 If qcApp.LoggedIn Then
  Print "User is Logged into ALM Server"
 Else
  Print "User is not Logged into ALM Server"
  Exit Function 
 End If
 'Connects user to specified Domain and Project
 qcApp.Connect sDomain,sProject
Set BugFactory=qcApp.BugFactory
Set Bug=BugFactory.AddItem(Nothing)
Bug.Status="New"
Bug.Summary="Test Bug"
Bug.Priority="3-Medium"
Bug.AssignedTo="Dev Team"
Bug.DetectedBy=myUserName
Bug.Post
Easy Way to Build this AOM file: Setup everything in UFT/QTP: Option 1: Go to test settings->General Tab-->Object Identification Tab-->Click on Generate button-->Provide the path-->Provide the name-->Click on save Option 2: Go to Test-->Settings-->Properties Tab-->Click on Generate button-->Provide the path-->Provide the name-->Click on save Option-3:Go to tools->Option-->General Tab-->Click on Generate button-->Provide the path-->Provide the name-->Click on save after few settings you will be able to understand the settings.
How To Work With Automation Object Model In UFT? How To Work With Automation Object Model In UFT? Reviewed by Animesh on May 25, 2017 Rating: 5

Top Nine Frequently Faced Issues for QTP/UFT with Solutions.

April 07, 2017
In this post, I going to concentrate the top ten frequently faced issues for QTP/UFT. Mostly we face these issues in our day by day testing.We google a lot and finally get the solution. I am trying to summarize them and jot down in point by point manner.

QTP does not throw any error but can not identify the objects.
Possible Solutions:
1.Check the builds if you have picked up correct build of application to test. This is one of the basic issue of today's testing process.Also it is always better to check the QTP build number.Here is a document on how to find out build.

2. Check the Zoom level. Sometimes increasing the zoom level will solve this issue.Mostly this issue occurs when we work on Pega application. Pega's layered approach gets hidden when it is not 100%. Sometimes to identify an element we need to Zoom in 125%.

3. Tabbed browser is not supported. Uncheck the Tabbed browsing option so that QTP/UFT can run smoothly.

4. QTP/UFT stops just after few lines may be 3 to 4 line in debug mode.F10 does not move the cursor to the next line.
The best possible issue could be lack of space in the drive where QTP/UFT is installed. Increase the space to accommodate the temp files.
Check for the RAM availability. If many processes are trying to get executed at the same time, QTP may get starvation issue.
If the above does not work out,reset the QTP/UFT to factory settings. Lastly you can uninstall and install it freshly.

5. Type casting error: It happens when we try to read data from datatable. It must take the parameter in a string but sometimes it fails to identify the data as a string.
Error code Error:Parameter <<VariableName>> should be srring but undefined.
Check the datatable column and convertible methods.Also check if the variable is defined or not.

6. Remote execution is fine and smooth so as local but even if you have good citrix net speed and local net speed you may face slow execution issue. QTP behaves like dead slow.
Similar like point no-4, Check for RAM size and available applications running along with citrix. Less RAM size and many parallel process may slow down the QTP/UFT execution process.

7. Excel connectivity issue. Every time office is upgraded to 2007 to 2010 to 2013 to 2017, QTP/UFT can not read execl. It stops,hangs,freezes during execution.
The best possible way to resolve this issue is to create connectivity with excel using ADODB.
Here is a good tutorial on the same.

8.Recored script does not work properly.Mostly while selecting values from drop downs. - Try to use descriptive programing. Most of the cases get resolved by this. if this does not solve this issue. try select (1) or select(#1).

9. We have licenses across teams. Client has given us total 10 licenses. When our team is trying to access QTP, QTP is throwing error saying no QTP available to use. This is a common issue in our team in our day to day use. Many of us do not shutdown/close QTP to terminate the session. We just lock the Screen to go home. This time UFT/QTP session is unused but can not be accessed.
To resolve the issue we need to use locked concept of QTP/UFT.In that case the licenses we will be locking will be available for our use.Other team can use remaining licenses(total licennses-locked licenses)
Here is a link that helps -https://community.hpe.com/t5/Unified-Functional-Testing/Locking-Code-for-QTP-QC-concurrent-licence/td-p/4488389

we can verify qtp software dump->license server -utilities ->winadmin.exe who are using the licenses.





image credit: www.information-age.com
Top Nine Frequently Faced Issues for QTP/UFT with Solutions. Top Nine Frequently Faced Issues for QTP/UFT with Solutions. Reviewed by Animesh on April 07, 2017 Rating: 5

Top Ten Strategies to Make Test Automation As a Service

May 08, 2016
Every journey towards automation  development is different from employees to employees and from companies to companies.Each one has some voice to venture.Some story to say. Some are good some are bad. Each story is unique.

Extensive testing before any release is not only necessary but also become essential for any company for their client and their clients's client,vendors,partners. Due to frequent change in IT industry,testcase base grows heavy in size. To run those huge cases,we need a strong manual team . Involvement of huge manual test engineers is nothing but loss human power.As they have to test the same test cases over and over for each release. Industry found out a common solution in the form of Automation testing. It is a sequence or series of actions performed by automation tool. The actions can or can not be dependent on human. During 2001 to 2005, the initial days of automation testing, automation team used to be a part of quality assurance or manual testing team.
A automation team was defined as a set of technology enthusiastic functional test engineers who writes VBA,or some small code base to make their job easy. Gone those days when team mainly used to depend on manual testing and automation was given a lower priority.

With the advancement of technology,languages, tools like automation,continuous integration,build and release team, VBscript, javascript ,Java,C# ,groovy, selenium, QTP, UFT, TOSCA,Silk automation testing took a greater stand in QA domain. Eventually during 2005 to 2010 unattended execution ,machine independent architecture , cross browser testing came to rescue development and QA. Slowly automation become a must go for any company's release cycle.Patch testing,Regression testing became very important for major players in software industry.The main purpose was to eliminate human related error from testing,speed up the execution and better ROI.

With the involvement of software design model like waterfall to v model to now days agile or rapid development ,automation becomes obvious. Agile and rapid development are meant to develop and change in a speedy way.So Automation needs to provide support in the same way.The nature of automation starts from unit testing to full execution, On demand execution to scheduled execution. Testing started rely on robot. Magnitude of testing is full day and night.When adopting such a huge speed, as a company, we need to adopt some strategies.
Here are the top ten strategies to make test automation as a service:

Must Read::Framework and Tool Evaluation  || Action Concept in QTP
1. When to use Automation:
Image Credit-http://www.snaptactix.com
Test Automation is a success in traditional way of testing in waterfall model, but a successful agile development can not really sustain without a good automated testing.
Go for automation testing if the project is long term and features will be tested again and again.Automation testing is only preferable if and only if the nature of testing is repeatable. Automation takes time to be mature but effective to catch bugs. It will give QA more confidence to look into the  non automated area.So use automation in such cases where-

  1. It saves time
  2. Increase accuracy
  3. Reduce cost
  4. Better ROI
  5. Better coverage
  6. Reusable
In agile when requirements may change every now and then, it is better to go for a TDD(Test Driven Development ) approach. This is surely ensure the proper and faster way of test development and execution.


2. Test Tool:

Image Credit https://www.qasource.com
Selection of the tool is very important as cost is associated with most of the tool.And Quality is associated with cost. Check for test tool compatibility with your UAT,the environment,browser.If Automation tool is compatible with your combination,half the battle is won. It is possible to test the environment in multiple language  along with normal testing.Once we get the correct tool for correct application , we will get more ROI.

Many a times, the tool sales person /team showcase their tool,in such  way, that the tool they are selling can automate everything a customer need. But reality is far from the show. So a expensive tool does not really make a functional team member an automation expert. Even they can not replace an automation expert.

Now the last aspect of tool selection could be o select some tool where your most of the knowledge base are. Simply if your resource is familiar to some technology or test tool or language, prefer the related tool.This will save time of initial learning and give automation a good start.

Test tool selection depends on the following factors:

  1. Affordability [Cost involves for this tool]
  2. Flexibility [How flexible the tool company about selling the tool or license]
  3. Compatibility [Can the tool support the UAT]
  4. Functionality[How easy the GUI or what feature the tool is offering]
  5. Usability[how easy to operate the tool]
  6. Maintainability [How easy to maintain the scripts]

If you are justifying a tool and not a member of management, please involve them from day one. And if you are a manager, please join the discussion to understand about the tool.If any team wants to get benefited with automation testing,management support is must. They must fund for R&D activities,pilot projects,fund for architecture development etc. Mostly it is top -down approach rather than a bottom up activity.

Must Read:: HTML Report in OATS::: HTML Report in QTP
3. Reporting:

Reporting should be the next major aspect of strategy. From the beginning, we need to standardize the reporting. Also we need to upgrade the reporting whenever necessary. Reporting should be customized or can be drilled to the lowest level. Creating various levels of abstraction is a very good approach.I like the jUnit/TestNG report for selenium. The consumers may be different for different level of reporting. Functional engineers may be drilling down till last level,Managers may be interested about how many scripts,how many pass etc. Top management may be looking at overall percentages.
Always tailor automation and information to meet automation objectives.
Must Read:: Top 12 framework Features:::Top 10 Framework Features
4. Framework:

We need to design a structured approach by which automation test engineers can produce maximum testcases by providing minimum efforts. We need to ensure maximum performance.Prepare best practices . Best would be to adopt a modular approach. Better to use a library driven approach rather putting everything in a script. Decomposition of the flow should be based on independent tasks. Not on the basis of  a big flow. The independent task lets call Units should have only one trigger point and only one outcome. With these units, one can make flows.
Always create layer of framework. The top layer should be a simple script with simple English. GEB and SPOC are very popular in this aspect. The test inventory should be very user friendly to a non technical user.
There are many IDEs(Integrated development environment) available in the market.One should design the framework such a way that it can overcome the limitation of the tool's GUI Part.
So framework development is not only a conceptual thing. There are finance area also attached to it. Be very careful to understand the requirements,tool selections and hiring.
5. Test Script:

Test script should be independent but structured. Each test case should be easy maintainable.Follow Hermetic Test Pattern  for test development. Even now single ton approach is also nice.Test cases should be accumulated in easy and random way. Functional team should set testcase as per their requirement.Decomposition of the flow should be based on independent tasks. Not on the basis of  a big flow. The independent task lets call Units should have only one trigger point and only one outcome. With these units, one can make flows.

Another way of automation is to check the heath of the test cases. And keep updating your inventory. The more we will test our testcases more we will get the quality. It will surely reduce  pesticide paradox in automation.

6. Clear Expectation:

Prepare a capability analysis of the engineers who are working in the team. second,prepare an estimation of the scripts according to the complexity[may be simple ,medium,complex,very complex]. Now set an target like in a day ,how many simple,medium,complex and very complex you can deliver.Estimate accordingly. I would suggest take 1-2 days buffer while planing and provide estimate accordingly.
Second important aspect is to get transparency. Yes. depending upon the maturity of the employees , we must be transparent to them. Information is power in our IT industry. In few cases, it is seen that the information is not shared to the team. Manager or lead poses to be over-smart thinks that this act gave them lot of power. Actually this is a poor managed team where actually nobody knows where the project stands.

7. Approach:

The best approach is to divide and rule approach. Look at your requirements then identify the smaller requirements. Now identify the smallest unit testcase that can be automated. Once this identification is done,look for reusable functions,common approaches. Build the helper functions. Then start automating with maximum re usability. In this way, many automation testcases can be automated within very short time.
Next to make test inventory scale-able and maintainable always depend on test data. Use testdata for triggering and running large scale testcase. There are many approaches to get or generate test data. But framework should support multiple format like-CSV,Spreadsheet,text file, random generation,xml. etc.Plug and play with these data source can give your test framework  wings.

Use different tools to understand the progress in milestone by milestone manner.Budget control,statistical tools like six sigma,lean,Failure analysis,Fish-bone, process control ,key performance indicators,regulars,Standardized reporting should be used to analysis different scenarios.
Retrospective meetings should be well prepared rather just jotting few points and go unprepared.
Every claim good or bad should be supported by supporting data.

8. Hiring:
In automation industry , we have two categories of test engineers.
1. Designer- Mainly Test Architect
2. Automator- Who will automate the test.

Automators are multi talented like a developer. They need to understand the requirements, create test case,create testscript,create supporting testdata, execute the test,analysis of the failures,re execution, reporting. So it is always better to have programming knowledge in automators.

How many engineers need to be hired depends on the load of work you will have. If the project follows waterfall model,you will get sometime to take a look of the work and estimate accordingly. But if the project follow a agile , then it is tough to get the projected load. So it is always better to have one or two shadow worker in buffer.Most of the companies now are creating talent pool.A pool of engineers with required skillset.

As I said earlier , It is no more a manual test engineer's job to automate application,It requires dedicated automation developer now a days. Apart from a dedicated team,the automation team requires a manager or a technical architect to drive the team. They should be from automation background. If the hiring is not correct way, like a manual test engineers given automation responsibilities or a manual manager is guiding automation team, then in most of the cases team lacks of motivation and innovation.

9. Operational Model:

As in agile methodology the load of the work is little unpredictable and requirements may get changed. As a result the traditional operative model of billing[Hours calculation,timesheet entry] may not work for both the vendor and client. In this changing moment of software development it may be good to go cloud's way of billing. Deliver the agreed quantity and get the billing. It is always a win win situation for both the parties as it follows pay as use mode. This solves the not used,un billable  resource problem. I have seen some model like the total no of scripts delivered, number of test execution happened,number of regression run,number of bugs logged.So according to your model,use quality center or jenkins to create more demand ,execution,daily execution,report to earn more.

Inside organization, follow different quality standard,documentation or CMMi level requirements.IT security,Data security,audit security,compulsory regulation,certification, quiz should be part of operation model. Employees should be encouraged to take the certifications,documentations,audit very seriously.

10.Do More with Automation:


Automation not only test your application but can do many more things. All tedious manual job like taking backup of the scripts,updating internal portal, posting report can be done with automation. I have heard one of the team automated the billing portal which was getting input data from review portal. I have experienced the automation of QC to OATS[Oracle Test Management] migration with the power of Selenium.
GUI testing is the mostly tested area in automation. But the success of GUI testing depends on many other factors. In my previous organization, in certain runs we have experienced 90% failures. While analyzing the failures we got to know that these were due to synchronization issue. Application was slow in nature. We use to give second round of execution of the failure testcases, and the 90% of them used to pass!!!.
After researching, we used direct database update,Seeded data and APIs to reduce the usage of GUI. That gave us speed of execution , less failure due to sync issues and more accurate bugs.
Well, more good was,we started supporting API testing as well.
Continuous Integration with automation testing is one of the prime factor for automation success.

These are the basic ten strategies that will surely support the TAAS. Let me know your views as well.








img credit-web.kalid.com.cn
Top Ten Strategies to Make Test Automation As a Service Top Ten Strategies to Make Test Automation As a Service Reviewed by Animesh on May 08, 2016 Rating: 5

Shall We Execute Our Automation Testcases in Random Order??

September 28, 2015
When I automate test cases, I always try to reuse what is already available in my test inventory. Always follow do not repeat yourself technique.  If atall components (functions, sub,procedure,testdata etc) are not matching with my requirement, I would create a new one.  Even there is a tendency to reuse the bunch of steps or bunch of tests even testsuite itself. Like me so many like minded persons available in information technology industry for sure.. :D

But as per testing best practice goes, we really need to improve our way of test development. As per that the best practice, we need to make test case independent to each other. There should not be any sharing between two test cases including test data.

Let us see with an example,what I am trying to venture through this post.

An example..
Lets say, I have to update a previously created employee who is attached to an organization.

So what are the manual testcase steps:
  • Create an Organization
  • Search for the same Organization and Create an Employee
  • Find the employee and find the organization and attach Employee to Organization
  • Now Update the same employee 

When I will automate the same flow I will create the structure like-

Testcase1: Create Organization
Testcase2: Create Employee
Testcase3: Attach Employee to Organization
Testcase4: Update Employee

Are test cases written in Big Ball of Mud test pattern correct?
With the advancement of testing,This is one of the basic test pattern where test assets are heavily shared between the test flows. Master driver or test suite can be also shared along with test data.There is no formal boundary or structure maintained to distinct between components[may be testdata,sub,macro,code etc]. Assume a scenario where a component of a test asset is reused by some hundred of test flows.Now to accommodate a new test case or a set of test cases we need to change the component a little bit. From the structural point of view as master drivers or test suites are shared,so we really do not know the impact of changing one component. With this approach it is very tough to find out which components use what all components.The change might fail some unnecessary test scripts in other area. So If we need to randomize the test cases designed in this pattern ,this might trigger failures. It will be needed for patchwork and workaround.So not so efficient way to execute them in random manner.

Are test cases written in spaghetti test pattern correct?
We will bunch these test cases into a batch called test suite and try to execute the same.
For this case we can simply put everything in a flow. Record playback like mechanism. Or we can divide the entire flow to sub flows[test cases] and stitch them. With this approach, each flow heavily dependent on the previous flow. As the state of the application is used by the next test case,so we can not run them individually. They are tightly coupled together. In such case the design pattern is spaghetti test pattern. So all test inventory which is having record playback framework and test cases  are tightly coupled ,we can not execute them in random order.

Are test cases written in Chain Linked test pattern correct?
Now where is Create Organization test case in inventory?? It is inside Organization module. Same like Create Employee will be inside Employee module and updating an employee may be in transaction or some other module. These type of approach where we will have different flows coming from different modules are upgraded from spaghetti test pattern.Each test case is considered as chain and bunch of chain hardly share the test data. But still it depends on the execution order to get the same state of application for the test cases.From the structure it is different from spaghetti model. Here the test cases are shared but the master driver or the test suite or the driver is independent of each other. Maintenance of this type of automation asset and  test data is a pain area for a organization. Mostly keyword driven framework, data driven framework, Modular decomposition approach,Function driven approach,Data oriented function driven approach follow chain linked test pattern. So randomize the test case execution may not suite for them.

The above three approaches talks about more re usability rather than independence of test cases.
 
public class updateEmployee{
@Test public void Create_Organization()
{
//Creation of org code goes here
}
@Test public void Create_Employee()
{
//Creation of Employee code goes here
}
@Test public void Update_Employee()
{
//Updating of Employee code goes here
}
}
With these kind of the approach the Test1 becomes the precondition for Test2 and Test1 and Test2 will both become precondition for Test3. These test cases can not be picked individually rather they needs to be run in a batch.

Advantages
  • No need to repeat the code.Optimum writing but maximum usage of test code
  • Structured or semi structured so finding out the batch and execute them is easy.
  • Mostly follows "do not repeat yourself" logic hence become modular with great ROI of automation.
  • Less execution time.

DisAdvantages
  • These type of test pattern mostly fail to give correct failure count.Or it is a constant pain for the test engineer to keep track. How? Let me explain... In the above test flow say Testcase-1[Create Organization] passed but Test Flow-2 [Employee Creation] failed. As Test case-1 and Test case-2 are precondition for Testcase-3 ,Hence Testcase-3 also will fail. or may not get executed depending upon your test configuration settings. So Report may look like Test-3 Passed-1 Failed-2. But no way, we can run these 2 failures. We need to execute 3 testcases once again. In an organization, in test inventory,thousands of scripts run.And if we consider ten parentage failures.We will have issues in reporting how much did we run really to get all test cases passed. Engineers need to be extremely careful to report
  • There is no way you can pick the failed test cases and execute them. As a result execution time becomes high. It becomes unreliable too
  • There is a huge chance that the polluted or corrupted test data may enter into next flow and may fail the flow.
Are test cases written in Hermetic test pattern correct?
Hermetic test pattern put more focus on test independence rather re usability. As per this test pattern each test case should be independent of each other. No sharing of test assets between test cases batched even in single test suite. Let us see how it will look like when we design our test cases as per Hermetic test pattern.
Test Name-CreateOrganization
 
public class CreateOrganization{
@precondition
//precondition steps go here
@Test 
public void Create_Organization()
{
//Creation of org code goes here
}
@Cleanup
//Cleanup code goes here ...here we delete all the test data created in the test. 
//Application goes back to original condition.
}


Test Name-CreateEmployee
 
public class CreateEmployee{
@precondition
public void Create_Organization()
{
//Organization Creation code goes here
//Create_Organization method of CreateOrganization testcase and 
//Create_Organization method of CreateEmployee testcase are different and has no link in between
}
@Test 
public void Create_Organization()
{
//Creation of org code goes here
}
@Cleanup
public void Delete_Organization()
{
//Cleanup code goes here ...here we delete all the test data created in the test. 
//Application goes back to original condition.
}
}

Test Name-UpdateEmployee
 
public class CreateEmployee{
@precondition
public void Create_Organization()
{
//Organization Creation code goes here
//Create_Organization method of CreateOrganization testcase and 
//Create_Organization method of CreateEmployee testcase are different and has no link/relation in between
}
@precondition
public void Create_Employee()
{
//Employee Creation code goes here

}
@Test 
public void Update_Organization()
{
//Creation of org code goes here
}
@Cleanup
//Cleanup code goes here ...here we delete all the test data created in the test. 
//Application goes back to original condition.
public void Delete_Organization()
{
}
public void Delete_Employee()
{
}
}


Advantages

  • Fully Structured and independent to each other so no problem to pickup any testcase and execute.
  • No polluted or corrupted test data propagation between tests
  • Uniquely identify the issues with testdata
  • Easy reporting and rerun report generation.

Disadvantages
  • Lot of refactoring required if we have a large test inventory prepared in other model
  • Need to prepare test data for atomic test cases which is a hectic job.
  • Execution time increases by multiple times.
So we need to take a conscious call if we will follow the hermetic design or batch mode test design . Mainly if we test a flow based scenario it is always better to go for batch mode test design.Other wise we must follow atomic test pattern or hermetic test pattern.
With hermetic test pattern we will be able to randomize our test execution.I always try to make testcases independent. If not possible or if that does not make sense, I go for batch mode or bunch mode and tag them differently.Mostly Smoke testcases[a set of testcases running day and night to make sure build is stable and correct],I prefer them independent and execute them in random order.

image Credit:pro-it-service.com
Shall We Execute Our Automation Testcases in Random Order?? Shall We Execute Our Automation Testcases in Random Order?? Reviewed by Animesh on September 28, 2015 Rating: 5

Four Commonly Used Methods on ComboBox in QTP

September 16, 2015
In an application today Combo box or select box or drop down is an essential part. Here developers provide choices that should be selected by user. Advantages of combobox or select box or dropdown is that it is single linear in view and restricts users to provide multi form of same data.
Very popular example could be country or state drop down. Say in a registration form ,User from India needs to select Country as India.But if this would have been a textbox, user might put Country -India  or INDIA or india. This will go to server as String.From technological point of view these are three different Strings!!!.
So by providing India on dropdown developers restrict user to select a single,defined String called India.

Commonly user methods on Combobox or Dropdown or select in QTP are-

  • Count of Items in Combobox or Dropdown or select
  • Fetch specific item from Combobox or Dropdown or select
  • Complete List of items from combobox or Dropdown or select
  • Select one from Combobox or Dropdown or select
Let us do one by one-
How to get Count of Items from Combobox or Dropdown or select
For getting count of Items from a Combobox or Dropdown or Select we will use getItemCount method.
Syntax-Variable_Name= <Hierarchy of Object >.Combobox("Combobox_name").GetItemsCount
dim x
x=Window("abc").WinComboBox("xyz").GetItemCount
//abc and xyz can be fetched from Object spy
//for descriptive programming
dim x
x=Window("Title:=abc").WinComboBox("name:=xyz").GetItemCount
How to get specific item from Combobox or Dropdown or select
For this case , the command we will be using is GetItem(Position).position starts from 0. It is nothing but Index value.
Syntax-Variable_Name=<Hierarchy of Object >.Combobox("Combobox_name").GetItem(2)
dim x
x=Window("abc").WinComboBox("xyz").GetItem(2)
//abc and xyz can be fetched from Object spy
//for descriptive programming
dim x
x=Window("Title:=abc").WinComboBox("name:=xyz").GetItem(2)
How to get complete list of Items from Combobox or Dropdown or select
For this we will be using GetContent method
Syntax-Variable_Name=<Hierarchy of Object >Combobox("Combobox_name").GetContent
dim x
x=Window("abc").WinComboBox("xyz").GetIContent
//abc and xyz can be fetched from Object spy
//for descriptive programming
dim x
x=Window("Title:=abc").WinComboBox("name:=xyz").GetIContent
How to select specific item from Combobox or Dropdown or select
Select is the command to set a value in the combo box
Syntax-
Variable_Name=<Hierarchy of Object >.Combobox("Combobox_name").Select(Value_To_Select)
or
Syntax-
Variable_Name=<Hierarchy of Object>.Combobox("Combobox_name").Select(Index_Value)
dim x
x=Window("abc").WinComboBox("xyz").Select("pqr")
//abc and xyz can be fetched from Object spy
//for descriptive programming
dim x
x=Window("Title:=abc").WinComboBox("name:=xyz").Select(2)
image credit :java.net
Four Commonly Used Methods on ComboBox in QTP Four Commonly Used Methods on ComboBox in QTP Reviewed by Animesh on September 16, 2015 Rating: 5

What are GetROProperty,GetTOProperty,GetTOProperties and SetTOProperty in QTP?

September 09, 2015
Developers develop application with different elements in any technology.They provide or maintain some basic information about the element.
Now While automating such application using QTP, we rely on QTP.It has its own mechanism to identify and learn about such properties of the application.These are standard object properties.
To begin with, let us understand few basic things..

  • TO--Test Object[standard]
  • RO--Runtime Object[standard]
  • Get--To fetch some value [kind of getter]
  • Set--To set some value [kind of setter]

Standard Object identified by QTP

Mercury now HP has created or defined Test objects according to the supported environment (web,ERP,Java etc).When QTP records an application,it tries to match the same list of properties for an Object and store them in Object Repository.
Navigate to Tools-->Object Identification

you can see the HP given/created Test Object properties:

For quick and steady access QTP stored them in registry as well:
The Path would be:
HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\<<ObjectName>>\Properties
or
HKEY_LOCAL_MACHINE\Software\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\<<ObjectName>>\Properties
depending upon license and installation.
For Browser
HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\Browser\Properties

However all these properties can be found under Help section of QTP.

In this post I trying to clarify different operation can be made through QTP on these objects.


GetROProperty:
When we do little advance programming in QTP, We need to fetch the value from the UAT. That becomes a standard requirement in QTP. Fetching value from application during run time was not so easy.QTP's advance programmer made it easy for all of us.
The technique is named as GetROPropery [Get Run time Object Property]
This command deals with the current value of the element.This can fetch values associated with runtime object.[During execution]. It can only be used on the properties that an element support during execution. Use Object Spy tool to identify compatible properties who's value can be fetched.We can use Regular expression too.

Example:
Browser("Google").Page("Google").WebEdit("q").set "AskQTP"
msgbox Browser("Google").Page("Google").WebEdit("q").getROProperty("Value")


 
It supports descriptive programming as well.
dim class_Name as String
class_Name=Browser("name:=Google").Page("title:=Google").WebEdit("name:=q").GetROProperty("nativeclass")


Name_of_variable[String]=<Fully Qualified DOM>.ObjectType<Object unique identifier>.getROProperty("Property Name")


Where we can use it?
Mostly finding combo items,getting title,getting table size,We will be using this methos.
It is bit advanced than standard or text check point.

General syntax is written below:


Here I have given more example of GetROProperties.
How to get number of links in a page.
Get URL value dynamically.
How to get StatusBar Message
How to get Browser Title
Number of Open Browser in Desktop
How to Capture Tooltips
How to close all browsers
How to Wok with Editbox
Commonly Used Functions in QTP
How too Retrieve element value in QTP

GetTOProperty:
GetTOProperty can fetch values associated with test object residing in Object Repository.In simple words,this command or function returns the properties and values which QTP has learnt during recording of the flow. It stores all values in Object Repository. During run time, QTP tries to match the same values with application's object to identify and perform operations..It reads all the value from object description.This can be used instead of standard check point to compare static values.

Syntax-
Variable_Name[of type String]=<Fully Qualified DOM>.ObjectType<Object unique identifier>.getTOProperty("Property Name")
Code:
dim class_Name as String
class_Name=Browser("Google").Page("Google").WebEdit("q").GetTOProperty("nativeclass")

It supports descriptive programming as well.
dim class_Name as String
class_Name=Browser("name:=Google").Page("title:=Google").WebEdit("name:=q").GetTOProperty("nativeclass")

During the use of GetTOProperty, many of us get the error called "Invalid procedure call or argument". Most likely this error comes when we are trying to get property value which is not listed or learnt by QTP during recording time.Use Object Spy to get the correct set of value to be fetched from object property.All it fetches the basic static properties of the test object.


GetTOProperties:
This is one advanced command or method over GetTOProperty. GetTOProperty deals with a single value. GetTOProperties can fetch multiple properties from a test object.Again the basic is same. These values need to be stored in Object Repository.
Syntax-
Variable_Name[of type String array]=<Fully Qualified DOM>.ObjectType<Object unique identifier>.getTOProperties

Example:
dim object_properties as String array
dim name as String
dim alt as String
systemUtil.Run "iexplore.exe","http://Google.com"
'Open google
Set ObjectEditBox=Browser("Google").Page("google").webEdit("q")
Set object_properties=ObjectEditBox.GetTOProperties
//This will fetch all TOProperties associated with editbox in the form of string array
for i=0 to object_properties-1
Name=object_properties(i).Name
alt=object_properties(i).alt
...
...
Next


SetTOProperty:
This method or command is used to modify a property value that QTP has learnt during record session and stored in Object Library.During recording QTP stores application properties and values in Object repository and during run session it creates a replica of the same.Then,tries to match all the properties and its corresponding values.By SetTOProperty we change the replica version of those object's property.So it is temporary and valid for each run session. After the run QTP restores the original values.

In this case the yellow box the original properties and values do not get affected.Mostly when there is no way to identify the object and no information available in Object Repository about the object we follow this approach to make QTP understand about the new Object.
Example:
Say in a page there two links available for a table view.

  1. GoNext-Upon clicking this Application will produce next 10 records
  2. GoPrevious-Upon clicking Application will produce previous 10 records.
So when we recorded,QTP learn about these two objects and stored in Object Repository.Now due to requirement change or any temporary change it becomes "Next" and "Previous". The working mechanism is same. As this is a temporary change so we will not change the Object Repository ,rather we will change the way QTP identifies these object in such case SETTOProperty will be handy. For that we will change the name property of these button.


Browser("ABC").Page("XYZ").webButton("GONext").SETTOProperty "name","Next"
Browser("ABC").Page("XYZ").webButton("GONext").Click

Browser("ABC").Page("XYZ").webButton("GOPrevious").SETTOProperty "name","Previous"
Browser("ABC").Page("XYZ").webButton("GOPrevious").Click
The only thing to remember before applying SETTOProperty is to disable the QTP's Smart Identification mechanism to identify the Object. Secondly,it is done in a encapsulated manner hence the screen (Active) or the Object Repository .So they will remain unchanged.
One more scenario could be , when we need to work with multiple instances of the same page,all objects will be same for this case. So while testing such instance we will be using SETTOProperty to identify them uniquely by providing separate names.
SetROProperty:
This is not available in QTP. Rather not required at all.During Runtime QTP is going to set the value anyway.This technique is important when QTP can not identify a text filed or some operation which QTP can not perform. We will adopt javascript executor in such case. Few QTP codes say it as SetROProperty. Let us discuss how:
set page=Browser("Google").Page("Google")
'setting the object for page
set googleTextBox=page.RunScript("document.getElementByName('q')(0);")
'Setting the object after finding in DOM
googleTextBox.value="AskQTP"

We can use getElementByID,getElementByXpath etc remember this is for fun and QTP does not have this method.
What are GetROProperty,GetTOProperty,GetTOProperties and SetTOProperty in QTP? What are GetROProperty,GetTOProperty,GetTOProperties and SetTOProperty in QTP? Reviewed by Animesh on September 09, 2015 Rating: 5

Which is better Xpath or DOM?

August 07, 2015
DOM:
The Document Object Model (DOM) is a cross-
platform and language-independent convention for
representing and interacting with objects in HTML,
XHTML and XML documents. Objects in the DOM
tree may be addressed and manipulated by using
methods on the objects.
Ex: var element=document.getElementById("intro");
XPATH:
XPath, the XML Path Language, is a query language
for selecting nodes from an XML document. In
addition, XPath may be used to compute values
 (e.g., strings, numbers, or Boolean values) from the
content of an XML document.
Ex: //input[@id=”xxx”]
 
They are complementary rather than competing. DOM provides a tree model of XML with low-level navigation capability (get first child, get next sibling, etc); XPath adds a much higher-level search and navigation capability

Note also that DOM is just one tree model for XML, and is very far from being the best: it's the first and the worst, and it's a shame that so many people still use it. In the Java world there are much better designs available such as JDOM and XOM.
But as starter I will remember DOM as the database and xpath is the SQL query.
Absolute Xpath :
1) start selection from the document node
2) Starts with //
3) e.g. “/html/body/p” matches all the paragraph elements
Google Search Box : /html/body/div[1]/div[2]/div[1]/div[1]/div[3]/div/div/div/form/fieldset[2]/div/div/div
Relative Xpath  :
1) start selection matching anywhere in the document
2) Starts with /
3) e.g. “//p” matches all the paragraph elements starts with p
Google Search Box : //*[@id='gbqfqwb']

image credit:developer.chrome.com
Which is better Xpath or DOM? Which is better Xpath or DOM? Reviewed by Animesh Chatterjee on August 07, 2015 Rating: 5

How To Create Test Data for Advanced Test Structure or Test Framework

August 07, 2015
In my last couple of posts, Structure of Automation Test Cases and
Best Test Structure::Hermetic Test Pattern , I have shown each testcase
should be independent to each other. But to make them real
independent it requires testdata manipulation. Testdata also need to
be independent ad unique in nature.

Why it is required?
It is required to stop data pollution.Stop using polluted data usage
inflow and outflow. 
I am writing few common methods to make testdata independent:

Ways:
  1. Use testcase id or name at the end of the testdata like Cutomer_Name=”Rabin”+”Test123”;
  2. Use time stamp to make testdata unique like-Customer_Name=”Rabin”+”3103201515082015”;
  3. Use random number generator to create unique testdata.like-“Robin”+rand.nextInt(900) + 100;
I like the Random number generation method and if it is not possible to use, I generally use the testcase id.
More note on Random number generation:
RandomStringUtils.random(10, false,true);

you need to import - org.apache.commons.lang3.RandomStringUtils package
this is very useful when generating 10 digit random number.
AtomicInteger counter = new AtomicInteger(1);
counter.getAndIncrement();

This is also very useful to get unique number.


image credit:http://www.sqledt.com/
How To Create Test Data for Advanced Test Structure or Test Framework How To Create Test Data for Advanced Test Structure or Test Framework Reviewed by Animesh Chatterjee on August 07, 2015 Rating: 5

Best Test Structure::Hermetic Test Pattern

August 07, 2015
In my last post-Structure of Automation Test Cases, I have shown how we can improve the test structure and make a better one.Too many tests will make feedback loop delayed and too less tests may not have enough coverage.Sometimes too many tests are added to a single E2E(End to End) script.This kind of test design will make it spaghetti. The goal is to design a significant approach that will lower down the feedback loop.
Now lets looks at the question below:

  • What is the biggest benefit or goal ? 
  • What is the cost ? 
  • How is the team? 
  • What training team needs? 
  • What is holding automation back? 
We have to prioritise the issues and resolve one by one. Now in this post I am trying to venture the pattern on which the structure is made. The test structure is made on Hermetic Test Pattern. As per the Hermetic test pattern each test should be completely Independent and should not depend on other test. So,It should be atomic in nature and self sufficient.As per the maintenance concern,each test case should be maintained concern,each testcase should be maintained separately and if any dependency outside of the test found(may be a 3rd party library,3rd party service) test engineer should cut the linkage with the service.
The best way to start is to look into smaller objectives but add test slowly to make it mature.
Advantages: Each testcases are atomic in nature so no dependency on anything. Test takes clean start as precondition creates all test data No polluted data inflow our outflow. We can execute the test in different order on need based. We can create more molecularity which increase code re usability. As each testcase is atomic,parallel execution is still possible.The deep advantages are:

  1. Increase confidence in software quality.
  2. Earlier time to produce the software to the market means more revenue.
  3. Reduce the cost in testing.
  4. Consistent repeatable testing
  5. Run tests unattended.
  6. Find more regression bugs
  7. Run tests more often
  8. Better quality software
  9. Coverage is high
  10. Find more bugs
  11. Test on different systems.


Disadvantages: Duplication of code increases if not created modular type. Design testdata for each testcase Execution time increases. High resource utilisation.
Best Test Structure::Hermetic Test Pattern Best Test Structure::Hermetic Test Pattern Reviewed by Animesh Chatterjee on August 07, 2015 Rating: 5

What Should Be The Structure of Automation Test Cases

August 04, 2015
A perfectly structured automation testcase should consist of four parts. They are:

  • Setup or precondition
  • main test
  • Cleanup or post condition
  • Optional code.


Precondition: All test data ot steps needs to be there in application or needs to be performed so that current test run/execute smoothly.

Main test: In this area the main objective of test case is being executed.

Cleanup: Here we delete all the testdata that is being created in the main test section.In other word we try to restore the out of box condition of the application. Why this is required?? Any accidental data pollution can be rectified.

Optional Area: All other user defined functions go here.
Class testcase1
{
precondition()
{
}
main()
{
functionx()
}
cleanup()
{
}
functionx()
{
}
}

Why we should do like this?

  • Well, while developing or refactoring we must understand our test goal.Each testcase should address only one requirement. Multiple requirement coverage in a single automation test may lead to confusion. It will hamper the traceability matrix as well.
  • By implementing the 3/4 folds we can reduce junk code creation. More encapsulation with less junk.
  • By implementing such structure we are making testcase independent. There is no dependency such that testcaseX needs to be executed in order run current testcase.So pulling of any testcase and re execution is possible.  
  • Also, we must check if we are generating redundant code /duplicate code.The more we will reduce the duplicate code more our test will become mature.A premature optimization is the main problem area of the organization.
  • Too big component or function would reduce the flexibility of reuse. So always create smaller components or functions and assemble them in last.
  • Too small components looses it significance . Mostly we overlook them. Those created but non utilized component or functions will become zombie. It is always better to use a higher level components out of lower level components.
  • The naming convention has to be as per business requirements. then it is easy to write,find and reuse. Freeform of coding loose these advantages .
  • Each low level components has to have a definite purpose.
  • Long term survival depends on the standard approach that aids the architecture.
  • Each small function or component should have a verification point.
  • Use of wait syntax is mandatory but can be updated with do until loop.
  • When something is getting changed in the application, we need to upgrade the low level components/functions. Maintenance become easy.


What Should Be The Structure of Automation Test Cases What Should Be The Structure of Automation Test Cases Reviewed by Animesh Chatterjee on August 04, 2015 Rating: 5

Microsoft VBScript runtime error: ActiveX component can't create object

April 24, 2014
Very recently I am facing this issue with one of the test machine. The DOS prompt says Microsoft VBScript runtime error: ActiveX component can't create object.

I have the following code:
Dim qtApp
Dim qtResultsOpt
Dim qtTestdir, resdir
Dim Shell

Set Shell = CreateObject("WScript.Shell")
qtTestdir =my test path
resdir ="my result path"
Set qtApp = CreateObject("QuickTest.Application")
If Not qtApp.Launched Then
  qtApp.Launch
End If
qtApp.Visible = True
qtApp.Options.Run.CaptureForTestResults = "OnError"
qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ViewResults = False
qtApp.Open qtTestdir, True
Set qtTest = qtApp.Test
qtTest.Settings.Run.OnError = "NextStep"
Set qtResOpt = CreateObject("QuickTest.RunResultsOptions")
qtResOpt.ResultsLocation = resdir
qtTest.Run qtResOpt
qtTest.Close
qtApp.quit
Set qtResOpt = Nothing
Set qtTest = Nothing
Set qtApp = Nothing


it was throwing error on the line no=10 that is Set qtApp = CreateObject("QuickTest.Application"). In the DOS prompt the error was pretty clear.
As usual , Google came all the way with bunch of suggestion distributed in different pages!!. I am just summarizing what I followed..

I just updated the code like

On Error Resume Next
Set qtApp = CreateObject("QuickTest.Application")
Msgbox Err.Number 

But to my surprise, it did not work. Some asked to increase the time as wait between the execution

On Error Resume Next
WScript.Sleep 5*60000
Set qtApp = CreateObject("QuickTest.Application")
Msgbox Err.Number 

Even that did not work.Then I googled more and found more suitable solutions.
1. Restart machine
2. Disable firewall and check
3. This is due to timing issue of creating ActiveX component object,when it is taking more time to open QTP more time like-5 mins.It gives me error in the line "Set objQTP = CreateObject("QuickTest.Application")" itself, before coming to line objQTP.Launch.And after the error it closes the QTPro.exe and QTAutomationAgent.exe processes that has been created due to CreateObject method, and objQTP is becoming null.
4. if it is Windows Vista Client you need to install QTP correctly.
  • Enabling UAC
  • Installing as User
  • Start QTP as Admin first.
5. Re register the QTP server using the below command
  • For XP:
    "C:\Program Files\HP\QuickTest Professional\bin\QTAutomationAgent.exe" /regserver 
  • For Windows Server
    "C:\Program Files (x86 )\HP\QuickTest Professional\bin\QTAutomationAgent.exe" /regserver 
Till now I had no success...what I thought that might be the QTP process had not been closed by the code. So I modified my code little bit..
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill 
strComputer = "."
strProcessKill = "'QTPro.exe'" 

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _ 
& strComputer & "\root\cimv2") 

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next 
I thought that it was the end of problem!!!

But to my bad luck, it did not work....Still I was getting ActiveX component can't create object error.

One of friend said to re-register the VBScript.dll
1.Open Command prompt from Run
2.Type regsvr32 %SystemRoot%\system32\VBScript.dll
3.Click on Enter
This is how we should re-register the dll file. or register the WScript object by running the wscript -regserver command from a command prompt or from the Run command on the Start menu
I was not convinced with the solution as I was not getting any error code.Interestingly at this point I hadm noticed that QTPro.exe was actually in the task manager. So QTP was actually running in the backend but not coming in the front. Problem became very complex at that time.

At this point of time an article published here,looked resolve my problem..
I recently helped someone who had the same problem, but with a VB Script application, executed with cscript.exe. This VB script application uses a 32-bit COM object and failed to run on a 64-bit OS. The error, Microsoft VBScript runtime error: ActiveX component can't create object: 'XXXXXX'.

To fix the issue, the script must be executed with the right executable. There are two cscript.exe in the 64-bit OSes. One is located at %WINDOWS%\System32, and the second one is located at %WINDOWS%\SysWOW64.

The one under System32, is a 64-bit version. The one under SysWOW64 is the 32-bit version. Run the VBS application using the 32-bit application.

Why System32 contains 64-bit binaries, and SysWOW64 contains 32-bit is another story, but there is a very good reason behind it, backward compatibility. :)
As I had no other choice, I tried to start QTP with this approach only. But !!!!! Still It was failing!!!!.

Suddenly I saw a pop up silently seating in the task bar. Very humble, it was saying there were 12 updates and needed restarts.Company policy needed to be updated.

I just allowed them to get installed..restarted 3 times...It worked like champ. VBS started wroking.
Microsoft VBScript runtime error: ActiveX component can't create object Microsoft VBScript runtime error: ActiveX component can't create object Reviewed by Animesh Chatterjee on April 24, 2014 Rating: 5

How To Get Desktop Path Dynamically In QTP

September 24, 2013
In my initial days with QTP, frequently I needed to download somefile to upload or download from or to the desktop.
To be in safe side I always used a Environment variable which carried the value of the Desktop path.
Like --Environment("Desktop").value= "path of the machine"

So in every release I use to tag this script as needs update during rerun in different machine.

Later I found a nice solution to find out the desktop path dynamically.

Set WSHShell = CreateObject("WScript.Shell")
strShortcutLoc = WSHShell.SpecialFolders("Desktop")

This is a Tested code which can be used to any machine. My problem resolved.
How To Get Desktop Path Dynamically In QTP How To Get Desktop Path Dynamically In QTP Reviewed by Animesh Chatterjee on September 24, 2013 Rating: 5

How To Solve Synchronization Failures In Selenium or QTP?

September 01, 2013
While automation testing using selenium tool for webpages , I am facing issue with Synchronization. Individually tests are passing. But while running in nightly mood manner, these are failing. One step failure leads to multiple failures in my testing.
I tried with Thread.sleep(30)..but found that is very much unreliable and prone to error. 
Thread.sleep will halt script at the step we are using and not at every step. selenium.setspeed halts script after each action/step performed on the application and this will be time consuming way.
I was googling for solution ..and I found this link http://mark-story.com/posts/view/selenium-synchronization-with-custom-events . This is a very nice solution indeed. Even the latches given here. . http://sauceio.com/index.php/2011/02/advanced-selenium-synchronization-with-latches/ is good to me. 

This is one important aspect of QTP automation test execution.Application speed depends on several external factors but QTP executes the code faster. In such condition it may so happen that QTP execution becomes faster than application . In this case execution fails.To avoid such condition we can use the below for synchronization:




  • Checkpoints applicable for UFT/QTP
  • Adding more sync time[wait]
  • Inserting synchronizing point
  • Through code like exists() or waitproperty()
In the same context, we can also see how to handle ajax calls:
Issues:

  • Partial loading of website: It can be addressed by 
  • try{
    thread.sleep(<required time>);
    }
    catch(Exception e)
    {
    }
    
    
  • Explicit wait:This will wait for a certain condition to occur before proceeding further
  • WebDriver driver=new FirefoxDriver();
    driver.get(URL);
    WebElement myDynamicElement=(new WebDriver Wait(driver,10)).until
    (ExpectedCondition.presenceofElementLocated(By.id("myElement")));
    
  • Implicit Wait: It is to tell webdriver to poll the DOM for a certain amount of time when trying to find an element if they are not immediately available. The default settings is zero.Once set the implicit wait, it is set for the life span of the webdriver object instance. It is taken from watir.
  • WebDriver driver=new FirefoxDriver();
    driver.manage().timeouts().implicitlywait(10,TimeUnit.SECONDS);
    driver.get(URL);
    WebElement element=driver.Element(By.id("myElement"));
    
  • Using Javascript
  • If an application triggers an ajax call, we need to wait until the call has ended. But using thread.sleep(),implicit or explicit wait is not clean and proper approach the browser does not change much while fetching data from server. jQuery keeps a count of how many ajax calls are active in its ajax.active variable. The implementation is described here
    public void waitForAjax(int timeOutSeconds)
    {
    try
    {
    if (driver instanceof JavaScriptExecutor)
    {
    JavaScriptExecutor jsDriver=(JavaScriptExecutor) driver;
    for(int i=0;i<timeOutSeconds;i++)
    {
    object numberOfAjaxConnections=jsDriver.executeScript("return jQuery.active");
    if(numberOfAjaxConnections instanceOf long)
    {
    Long n=(Long) numberOfAjaxConnections;
    if(n.longValue()==0L)
    {
    break;
    }
    Thread.sleeep(100);
    }
    }
    catch(InterruptedException e)
    {
    }
    }
    
  • Using Fluent Wait
  • Selenium webdriver provides Fluent wait option to handle uncertain waits. The advantages of this approach is that element polling mechanism is
    FluentWait<By>fluentWait=new FluentWait<By>
    (By.tagName("TextArea"));
    //description of the element for which we want to poll
    fluentWait.pollingEvery(300,TimeUnit.MILLISECONDS);
    //it will ping in every 3 seconds
    fluentWait.withTimeOut(1000,TimeUnit.MILLISECONDS);
    fluentWait.until(new Predicate<By>(){
    public boolean apply(By by)
    {
    return browser.findElement(by).isDisplayed();
    }
    catch(NoSuchElement ex)
    {
    return false;
    }
    }
    });
    browser.Element(By.tagName("TextArea")).sendKeys("Hi");
    
  • Using WebDriver Wait
  • public ExpectedCondition<WebElement>
    visibilityElementLocated(final By by)
    {
    retuen new ExpectedCondition<WebElement>()
    {
    public WebElement apply(WebDriver driver)
    {
    WebElement element=driver.findElement(by);
    return element.isDisplayed()?element:null;
    }
    };
    }
    public void performSomeAction(){
    //your code
    Wait wait=new WebDriverWait(driver,20);
    WebElement element=wait.until(visibilityofElementLocated(By.tagName("a")));
    }
    
    
    
    

How To Solve Synchronization Failures In Selenium or QTP? How To Solve Synchronization Failures In Selenium or QTP? Reviewed by Animesh Chatterjee on September 01, 2013 Rating: 5
Powered by Blogger.