Sunday, June 10, 2018

Protractor - Getting browser log

Sometimes we need to get browser console information to validate tests. Protractor has ablity to retrieve the console info.

Need to add LoggingPrefs into config file and then you can access browser console info as per below code.

config:
'browserName': 'chrome', name: 'chrome-scripts', count: 1, loggingPrefs: { "driver": "INFO", "browser": "INFO" }



Code:
browser.manage().logs().get('browser').then(function(browserLog) { console.log('No of info from console:' + browserLog.length); browserLog.forEach(function(logInfo){ console.log('browser console info: ' + require('util').inspect(logInfo)); consoleInfo = require('util').inspect(logInfo); if (consoleInfo.indexOf('name:') !== -1) { expect(consoleInfo).toContain(fileToUpload); } else if (consoleInfo.indexOf('size:') !== -1) { expect(consoleInfo).toContain(fileSizeInBytes); } }); });



Sunday, October 22, 2017

CDrive free space was going down

My HDD free space is usually 30 GB. On weekends in last month, I noticed that machine performance was too slow. Then I checked HDD free space, which is less than 10GB. Used system cleanup for C Drive and got another 500 MB space.

Did few google search and found utility - TreeSize to get to know the utilized space by each directory.

Lastly found that Office cache had more than 30 GB for Office 2015 and Office 2016 versions. Removed all cache from following directories and Machine performance is so much better.
**Office Cache - C:\Users\\AppData\Local\Microsoft\Office\16.0\OfficeFileCache1
**Office Cache - C:\Users\\AppData\Local\Microsoft\Office\15.0\OfficeFileCache
**Office Cache - C:\Users\\AppData\Microsoft\Office\15.0\OfficeFileCache

Monday, September 18, 2017

Invoking OneDrive for Business App

Using OneDrive for Business app for few years to sync official related documents. Much useful to share the documents with colleagues.

Couple of times, I noticed that after OneDrive app is not there after restarting the system. Tried different solutions and this one is working always. To invoke the OneDrive app, you open 'OneDrive.exe' under your profile ==> [C:\Users\[userId]\AppData\Local\Microsoft\OneDrive\]


Friday, May 5, 2017

Big Data Testing - Part 1

Today many enterprise companies have flooded with data. Current technological advancements have led to overwhelming amount of data from distinctive domains like internet of things (sensors), health care, ecommerce and financial companies. The term big data was coined to capture the meaning of this emerging trend.

Big Data is helpful to take better business decisions on different kind of business. The data should not contain any bad data and incomplete data. It has different analytics for variety of business needs. It is used in customer segmentation, Product performance, fraud detection, social media analytics, sentimental analysis, predictive analytics, Financial risk analysis etc.

Big Data Ecosystem

A generic big data implementation has four stages:
  1. Capture Data from multiple sources (Data Ingestion)
  2. Storage for huge data
  3. Data Processing (Loading and transformation)
  4. Analyze layer (Analytics & Reports)

Like components ecosystem, the big data system can be decomposed into a layered structure and divisible into three layers, i.e., the infrastructure layer, the computing layer, and the application layer, from bottom to top. This layered view only provides a conceptual hierarchy to underscore the complexity of a big data system.

Big Data Testing Approach
Bad data can cause great difficulties for analysis and make decisions. Also, Poor implementation can lead to poor quality, delays in testing and increased cost. The right test strategy should ensure both functional testing and non-functional testing.

Test approach can be varied based on type of data processing like Stream processing and batch processing and type of analytics solution used. If big data implementation has less stages or few components and Testing techniques also will be reduces based on components availability.


Functional Testing
  • Data Flow Validation
  • Data Integrity
  • Data Ingestion Layer validation
  • Data Storage Layer
  • Data Processing Layer
  • Analytics & Reports Layer

Non-Functional Testing
  • Data Quality Monitoring
  • Infrastructure
  • Data Security
  • Performance Benchmarking
  • Fault Tolerance
  • Fail Over Mechanism

Will explain each of testing in next post.

Saturday, March 25, 2017

Tools learning for testing

Many times folks used to ask, what tools would be good for testing career. Used to advice to learn popular tools (mostly commercial tools) based on their coding skills and interest. But this scenario is changed in last few years. Testers should be ready to handle the automation based on business needs, rather than just toolsmiths. Also mindset change should be there, instead of sticking with just one tool and one scripting language

Read an article recently in this line and few excerpts..


It’s important to ask yourself, why do you want to learn about a specific tool or set of tools? They are an integral part of software testing, supporting what we do on a daily basis. However, having knowledge of a set of tools is less important than knowing when and where to use the right tool. An effective tester will also have the skill to know when and where to use the right tool because the problem requires it, not because the job market determines it desirable. Using the wrong tool at the wrong time can have adverse effects on your day-to-day work, potentially slowing you down, or worse, giving you biased or flat out false information. That’s not to say you shouldn’t explore new tools, but always remember:

Problem first, tools second
With this concept in mind, let’s explore different categories of tools. Some examples will be offered but they are by no means an exhaustive list. I encourage you to build up a toolbox or reference list of tools you have used in the past.


Original Article - What Tools Should I Learn?

Sunday, March 19, 2017

Handling multi-dimensional array in vbscript

Was trying to build excel data provider, which can be used for Test Complete and QTP scripts. Created a VBScript to keep all excel contents into a multi-dimensional array.

Problem
Declared array with lower limits and then used ReDim to fix with right count. But I was able to retrieve the data only upto the initial array size.

Solution:
Tried different ways. Then declared array without any size as given in below code.

Code:
'------------------------------------------------------------------------- ' File : ExcelReadByArrays.vbs ' Author : PalaniSelvam Thillaiappan ' Purpose : To read the given sheet contents . '------------------------------------------------------------------------- '' Usage '' cscript D:\MyCode\qtp_uft\ExcelReadByArrays.vbs '' test data: D:\MyCode\qtp_uft\testMyApp_1.xlsx '******** Variables Declaration Dim gsExcelFile, giStartRow, giStartCol, giEndRow, giEndCol, giSheetIndex Dim gsLogFile Dim arrExcelData() 'as all Rows data '''Dim arrExcelData(5, 5) 'as all Rows data giSheetIndex = 1 gsExcelFile = "D:\MyCode\qtp_uft\testMyApp_1.xlsx" '' Working fine, but array size should be given properly ExcelDataRead gsExcelFile, giSheetIndex, arrExcelData PrintArrays arrExcelData '-------------------------------------- ' Method : ExcelDataRead ' Author : PalaniSelvam Thillaiappan ' Purpose : Read all the contents from Excel sheet and write into log file ' Parameters: sExcelFile - String, contains the Excel file ' : iSheetIndex - Integer, Value for Sheet Index '-------------------------------------- Sub ExcelDataRead(sExcelFile, iSheetIndex, ByRef arrExcel) Dim sExcelPath 'As Variant 'Excel file '********** Excel object declaration **********' ' Excel Application object Dim objExcel 'As Excel.Application Dim objXLWorkbooks 'As Excel.Workbooks Dim objXLWorkbook 'As Excel.Workbook Dim WorkSheetCount 'As Variant 'Work sheets count in a excel Dim CurrentWorkSheet 'As Excel.Worksheet ' Current worksheet Dim objCells 'As Excel.Range Dim objCurrentCell 'As Variant Dim objFont 'As Variant ' Result contents Dim sCellText 'As Variant Dim sFontName 'As Variant Dim sFontStyle 'As Variant Dim iFontSize 'As Variant Dim iCellTextColorIndex 'As Variant Dim iCellInteriorColorIndex 'As Variant Dim sResult 'As Variant Dim sChartFile 'As String ' Row and Col integer variables Dim iUsedRowsCount 'As Integer Dim iUsedColsCount 'As Integer Dim iTop, iLeft 'As Integer Dim iRow 'As Integer 'Row item Dim iCol 'As Integer 'Col item Dim iCurRow 'As Integer Dim iCurCol 'As Integer Dim arrColList 'As Array - Column Name If (sExcelFile = "") Then sExcelPath = "D:\MyCode\qtp_uft\testMyApp_1.xlsx" Else sExcelPath = sExcelFile End If If (iSheetIndex = "") Then iSheetIndex = 2 End If Set objExcel = CreateObject("Excel.Application") objExcel.Workbooks.Open sExcelPath, False, True On Error Resume Next WorkSheetCount = objExcel.Worksheets.Count Set objXLWorkbook = objExcel.ActiveWorkbook 'objXLWorkbook.RunAutoMacros Set CurrentWorkSheet = objExcel.ActiveWorkbook.Worksheets(iSheetIndex) 'iSheetIndex worksheet iUsedRowsCount = CurrentWorkSheet.UsedRange.Rows.Count iUsedColsCount = CurrentWorkSheet.UsedRange.Columns.Count iTop = CurrentWorkSheet.UsedRange.Row iLeft = CurrentWorkSheet.UsedRange.Column CurrentWorkSheet.UsedRange.Columns.AutoFit() ' Cells object CurrentWorkSheet.Cells.Activate ReDim Preserve arrExcel(iUsedRowsCount, iUsedColsCount) ''ReDim arrColList(iUsedColsCount) For iRow = iTop To iUsedRowsCount '(iUsedRowsCount - 1) 'Read All Columns For iCol = iLeft To iUsedColsCount '(iUsedColsCount - 1) sResult = "" Set objCurrentCell = CurrentWorkSheet.Cells(iRow, iCol) sCellText = objCurrentCell.Text sResult = "Reading Cell {" & CStr(iRow) & ", " & CStr(iCol) & "}^" & sCellText & "^" WScript.echo sResult Set objCurrentCell = Nothing arrExcel (iRow-1, iCol-1) = sCellText Next Next ' This will prevent Excel from prompting us to save the workbook. objExcel.ActiveWorkbook.Saved = True Set CurrentWorkSheet = Nothing 'objExcel.Worksbooks.Close objExcel.Quit ''Set CurrentWorkSheet = Nothing Set objExcel = Nothing 'MsgBox "Read Completed.", vbOKOnly, "Exec Over" Exit Sub ErrorHandler1: 'MsgBox "Error # " & CStr(Err.Number) & " " & Err.Description 'Err.Clear ' Clear the error. End Sub '' To display given array Sub PrintArrays( arrList) '' To Print all list items Dim aValue 'array item ==> dictionary Dim aItem 'dictionaly item ==> key-pair value Dim iRow Dim iCol WScript.echo "Array Rows Count: ",UBound (arrList, 1) '' First Array WScript.echo "Array Columns Count: ",UBound (arrList, 2) ''Second Array For iRow =LBound(arrList) to UBound (arrList)-1 For iCol=LBound(arrList,2) to UBound (arrList,2)-1 aValue = arrList(iRow, iCol) WScript.echo iRow, iCol, " Value:", aValue Next Next End Sub



Sunday, July 10, 2016

Comparison of C# and Java for testers

was talking with few test professionals for C# automation. Team is reluctant to change from Java background to C# technologies. I have used many scripting and programming languages. There is not much variation between Java & C# at core langulage level.

Differences and similarities

DescriptionJavaC#
Program Entry Pointmain(String ...args) Main() or Main(string [] args)
Smallest Deployment UnitJarEXE/DLL, Private Assembly, Shared Assembly
SigningJar SigningAssembly Signing
Namespacepackage namespace
Including Classesimportusing
Inheritanceclass (extends), interface (implements)class and interface (:)
Visibilityprivate, package,protected, publicprivate, protected, internal,internal protected, public
Abstract Classabstract class X { ... }abstract class X { ... }
Non-Extensible Classfinal class X { ... }sealed class X { ... }
Non-Writable Fieldfinalreadonly
Non-Extensible Methodfinalsealed
Constantstatic finalconst
Checking Instance Typeinstanceofis
Enumsenum, can have fields, methods and implement interfaces and are typesafeenum, cannot have methods,fields or implement interfaces, not typesafe
for-each constructfor (item : collection)
{ ... }
foreach(item in collection)
{ ... }
Switch-Casenumeric types (int,float...) enums, and now strings (in Java 7)numeric types, enums and strings
Method ParametersObject References are passed by Value onlyObject reference are passedby Value(default), ref & out
Variable Argumentsmethod(type... args)Method(params type[] args)
Catching Exceptionstry { ... } catch (Exception ex) {...}try { ... } catch (Exception ex) {...}
Meta TypeClass klass = X.class;Type type = typeof(X);
Meta Information@Annotation[Attribute]
Static classSimulated by private Ctor and static methodsStatic class and ctor with static methods
PropertiesgetProperty(),setProperty()Property { get; set; } compiler generated get_Property() and set_Property() methods


Selenium script on Java & C#
Developed a sample selenium scripting using Java and ported to C#.




Reference Links

Moving to C# for Java Developers
Java Vs C#

Thursday, July 16, 2015

Dynamics AX Performance Testing by using Coded UI tests

Recently we have completed Dynamics AX performance testing by using functional test automation scripts, which were developer by using Visual Studio - Coded UI. Dynamics AX thick client performance testing was time consuming using X++ code approach - Benchmark Toolkit. I'm into Test Automation for many years and had few challenges to implement functional test scripts as performance Testing. Used Microsoft Terminal servers to simulate multiple users RDP sessions. Prepared the list of factors, which are considered as helpful in this methodology.

Best practices for coding
  • Don't open the AX thick client for each iteration. For example, Sales Order creation should be executed for 15 times per user. Open AX thick client only once per user and then create 15 Sales order without re-starting AX client
  • Open AX client from windows path. Don't use shortcuts to open. Also keep the same path should be available in all terminal servers.
  • Methods to log Start Time and End Time for particular transaction
  • Don't use too much descriptive OR heavy programs to find the controls. Keep in mind that Testing tool also will consume CPU and memory
  • Don't keep control identifying calls within the time measuring statements. There is a major difference on purpose of functional script and performance script.
  • You can use UI Map (Object Repository) OR Page object model
  • Try to use short-cut keys. It would simplify your script as well as increase the execution speed
  • Introduce the loop within the test method. Don't call test method multiple times
  • Use data sources to provide different test data for each user. Try to read once and then use, whenever it required
  • Implement time logging only at essential code. Also consider that Automation tool would take few seconds to identify particular screen/UI object
  • Run with few users and validate once the script/ scenario is complete
  • Avoid left click navigation by entering module directily in address bar
  • Use Sleep between transactions, but do not include in transaction timings
  • Refine the steps, wherever possible
  • Follow naming conventions for transaction name, which should be simple and ease of use


Best practices for Performanc Testing related
  • Transaction timings can be logged as XML, TXT, DB records etc. I would prefer to keep in Database. SO that you can save the data multiple times and also use queries to collect different kind of metrics like Average Response time, 90th Percentile response time, Minium Response time, Maximum Response time etc.
  • Create couple of methods to log start and end timings for each transaction
  • Capture the script errors as well as AX exceptions
  • Update the information for
  • Implement test method to be executed for the given time using config file. For example, the scripts have to be executed 60/90/120 minutes
  • Implement user frequency. For exmple, if Sales Order should be created 15 times per user, then script should be stopped after creating 15 Sales order for each user
  • Capture screenshots if test is failed for any user. Keep the images in shared path. Also create less size image.
  • Modify the script, which is creating more transactions than expected
  • Validate each transaction time as whether only applicaiton time OR included Coded UI time as well
  • Keep data files in the shared path for ease of use and maintenance
  • Use Visual Studio Load test to collect performance counters from various servers like AOS servers, AX Batch servers, AX Integration servers, Terminal servers etc


Batch files to execute CodedUI Tests
Always create DLLs in Release mode instead of Debug mode. It will improve system's resource utilization.
echo on set logfile=C:\AX_PerformanceTest\ExecSmallSO.log echo "%date% - %time%- MediumSO started" cd\ cd "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow" vstest.console.exe "C:\AX_PerformanceTest\DLL\AX_PerformanceTest.dll" /Tests:CreateSmallSaleOrder pause


Sample Coded UI methods
Scenarios should be carefully implemented as it is for performance testing.
public void clickSellTab() { axAppWindow.SetFocus(); myutils.ClickButton(axAppWindow, "SellTab"); } public void ClickBookMenu(ref Logger.Logger LogObj) { try { axAppWindow.SetFocus(); WinMenuItem item = new WinMenuItem(axAppWindow); item.SearchProperties[WinMenuItem.PropertyNames.Name] = "Book"; UITestControlCollection ab = item.FindMatchingControls(); LogObj.TransactionStart("BookingOrder"); Mouse.Click(item); Thread.Sleep(1000); this.clickSellTab(); // axAppWindow.WaitForControlEnabled(50000); axAppWindow.SetFocus(); item.WaitForControlReady(50000); LogObj.TransactionEnd("BookingOrder"); } catch (Exception ex) { LogObj.LogException(LogObj.ScenarioName, ex.ToString()); } }


Few links related to Coded UI Tests


Friday, May 22, 2015

Sharepoint Test automation using CSOM

Microsoft has provided Client Side Object Model (CSOM) to interact with Sharepoint objects easily. This CSOM objects can be interacted through Powershell and C#. Many developers are also using this to do CRUD[Create, Read, Update and Delete] operations. Testers can use CSOM to validate site columns, various content types and content data. Also it can be used to create test data for various content types.

I have used this library - SharePoint Test Automation using Client Side Object Model (CSOM) for my sharepoint projects. Used to validate site columns, available sites content types and content fields.

Follow the steps to begin your automation. Also it is API-based automation, no need to worry about UI changes...

Step 1: Download and Install Client Components from SharePoint Test Automation using Client Side Object Model (CSOM)

Step 2: Once installed, Add the following references in the package.
- Microsoft.SharePoint.Client
- Microsoft.SharePoint.Client.Runtime

Step 3: Develop code for Test Initialize like below.
using System; using System.Configuration; using System.Text; using System.Collections.Generic; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using Test.Automation.SharePointCOM.Verification; using Test.Automation.SharePointCOM.Helpers; using System.Net; using Microsoft.GD.Test.Logging; using System.IO; using Microsoft.SharePoint.Client; using AutomationFramework.TestScripts; namespace AutomationFramework.TestScripts { [TestClass] public class SpAppVerify { SPVerification VerifyCO; LogFile TestResults = new LogFile(); private TestContext testContextInstance; public static string sURL = "https://teams.SpApptest.com/sites/cthub"; public static string sUsrId = "svc-spfarm"; public static string sUsrPwd = "SpAppdev#123@"; public static string sUsrDomain = "devSpAppnai"; private String sTestLogFile = ConfigurationManager.AppSettings["ResultsLog"]; public TestContext TestContext { get { return testContextInstance; } set { testContextInstance = value; } } [TestInitialize] public void Setup() { // The below two lines help to access HTTPS site System.Net.WebClient client = new System.Net.WebClient(); ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; VerifyCO = new SPVerification(); testContextInstance.WriteLine("==============Starting the Set Up====================="); Assert.IsTrue(VerifyCO.SetSiteUnderTest(sURL, sUsrId, sUsrPwd, sUsrDomain, testContextInstance)); testContextInstance.WriteLine("==============Ending the Setup====================="); }


Step 4: Site Column validation
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", @"C:\Automation\SpApp_Tests\CoreLibrary\TestData\sitecolumns.csv", "sitecolumns#csv", DataAccessMethod.Sequential), TestMethod] //[TestMethod] public void VerifyCOSiteColumns() { TestStartMessages(testContextInstance); VerifyCO = new SPVerification(); String ColumnName = testContextInstance.DataRow["SitecolumnName"].ToString(); VerifyCO.SetSiteUnderTest(sURL, sUsrId, sUsrPwd, sUsrDomain, testContextInstance); TestResults.LogMessage(testContextInstance.TestName + " SitecolumnName : " + ColumnName); TestResults.LogAssert(VerifyCO.VerifySiteColumns(ColumnName, testContextInstance, "SitecolumnName", "SpApp Site Columns")); }


Step 5: Content Type fields validation
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", @"C:\Automation\SpApp_Tests\CoreLibrary\TestData\ContentTypes\SpApp Web Page ", "SpApp Web Page#csv", DataAccessMethod.Sequential), TestMethod] public void SpApp_Web_Page() { TestStartMessages(testContextInstance); VerifyCO = new SPVerification(); VerifyCO.SetSiteUnderTest(sURL, sUsrId, sUsrPwd, sUsrDomain, testContextInstance); String TypeName = testContextInstance.DataRow["ContentTypeName"].ToString(); String ColumnName = testContextInstance.DataRow["ColumnName"].ToString(); String Field = testContextInstance.DataRow["Type"].ToString(); // Assert.IsTrue(VerifyCO.VerifyContentTypeField(TypeName, ColumnName, Field, testContextInstance)); TestResults.LogMessage(testContextInstance.TestName + " : " + TypeName + " : " + ColumnName + " : " + Field); TestResults.LogAssert(VerifyCO.VerifyContentTypeField(TypeName, ColumnName, Field, testContextInstance)); }


Step 6: Bonus code - To get all fields of content types in the given site.
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", @"C:\Automation\SpApp_Tests\CoreLibrary\TestData\AllContentTypes.csv", "AllContentTypes#csv", DataAccessMethod.Sequential), TestMethod] public void Get_All_ContentTypes() { bool result = false; String sContentInfo; FieldCollection Fields; TestStartMessages(testContextInstance); VerifyCO = new SPVerification(); VerifyCO.SetSiteUnderTest(sURL, sUsrId, sUsrPwd, sUsrDomain, testContextInstance); // SharePointHelper spSharePointHelper = new SharePointHelper(sURL, sUsrId, sUsrPwd, sUsrDomain); String TypeName = testContextInstance.DataRow["ContentTypeName"].ToString(); Fields = VerifyCO.GetAllContentTypes(TypeName); if (Fields != null) { TestContext.WriteLine("Found the Content Type : " + TypeName); TestResults.LogMessage("Found the Content Type : " + TypeName); // FieldCollection Fields = spSharePointHelper.GetFieldsOfContentType(TypeName); foreach (Field fieldItem in Fields) { sContentInfo = "Title: " + fieldItem.Title; sContentInfo += " DisplayName: " + fieldItem.TypeDisplayName; sContentInfo += " Description: " + fieldItem.Description; sContentInfo += " Default Value: " + fieldItem.DefaultValue; sContentInfo += " Required: " + fieldItem.Required.ToString(); //sContentInfo += "DisplayName: " + fieldItem.TypeDisplayName; TestResults.LogMessage(sContentInfo); } } else { TestResults.LogMessage("Not Found Content Type : " + TypeName); TestResults.LogMessage(" "); } }


Links For Sample code

Using the C# CSOM to interact with SharePoint Online

Use C# CSOM ClientContext to download file from SharePoint document library or OneDrive for Business


Saturday, March 7, 2015

CodedUI Useful links

In recent yearts, CodedUI has been improved lot. Using latest version of VS, we can automate windows apps and windows phone apps. Below links are giving more info and how to use Coded UI for different applications.

CodedUI Resources
Verifying Code by Using UI Automation
Hand Coding a CodedUI test
How To: Automating Custom controls through CodedUI