LayoutTitle

Hoverable Dropdown

Monday, March 11, 2019

Sample Behavioral Driven Development (BDD) Project for your reference



While working on Behavioral Driven Deployment (BDD) you should have the following ready in your desktop

1. Any IDE (Eclipse any versions or IntelliJ) - to develop the project
2. Latest JDK installed
3. Latest Maven installed
4. Configure Settings.xml file - You will find this file from the config folder of Maven repository that you have downloaded. Take a copy of that file and paste at the following location (at your profile path) as stated and change the information related to Proxy and repository path
Your profile path : C:\Users\<<YourLoginUserID>>\.m2
5. Then install Selenium and other 3rd party add-on's as per your project requirement, example like install Cucumber for BDD etc.,


Behavioral Driven Deployment (BDD)

In general, the BDD is a common write up written in English language with few keywords like Scenario, Scenario Outline, Given, When, Then, And, Examples etc., This language named as Gherkins language.

Example 1: Story with Test Data

Scenario Outline: TC 1 - create a order form E-commerce website
Given User launches any E-commerce website
When select a order and select Payment Mode as "<DebitCard>"
Then user will get the orderNo created for future tracking

Examples:
|DebitCard|
|123456789|
|987654321|

Example 2: Story without Test Data

Scenario : TC 1 - create a order form E-commerce website
Given User launches any E-commerce website
When select a order and perform Payment
Then user will get the orderNo created for future tracking



Here you need to start with creating feature file by writing Story/Stories using Gherkins language. Below snap shows you the Maven dependency added for Cucumber (marked as 5). Hence it allows you to write the Story (marked as 1) in the feature file.





Once you started writing each line in the feature file, the Cucumber prompt you to add each Step to the Step Definition file (marked as 2). In turn, you will have a link to the step definition for each of your feature step line.





Once you started defining the step definitions, you have to write the implementation code to each of these step definition. This step definition in turn will have link to the page definition (marked as 3). Mostly, you will be having navigation or work flow of the business logic and implementation part in the page definition.




Here after, you will have detailed code starting from the declaration of each object to code implementation.  Here you will follow Page Object Model (POM) to have a no dependency on each of your code implementation. To achieve this you will be using Setter and Getter methods (means adopting Data Encapsulation).





To have Test Data to your Story using the Examples keyword or write your own or separate utility using POI & JXL Libraries and read or write from or on to the excel sheet (marked as 4)



Thursday, March 7, 2019

What is the difference between normal Java Project and Maven Project?



Here are the few points on the differences on normal Java & Maven Project

1.   Normal Project & Maven Project structure vary, see below. Observations are here you won't see the Maven Life cycle and also POM doesn't preset. Moreover you can run the java class by right clicking as shown below

      
Normal Java Project  & Its folder structure
Maven Java Project & Its folder structure

      NOTE: Maven project shows POM file and also Maven Life cycle to perform the desired action and also you can run the Java class by setting the run configuration under Maven project

2.  Maven Project only will have Project Object Model (POM) file
3.  Maven is a software project management and comprehension tool hence it will manage a project's build, reporting and documentation automatically from a central piece of information.
4.  Maven itself has life-cycle which includes clean, validate, compile, test, package, verify, install, site and deploy of your project created. These life-cycle helps you to perform relevant activities automatically unlike you do all these activities with great difficultly manually in Normal Java projects
5.  While creating Maven one should provide group id, artifact id & version for your project. These information helps you in identifying your project uniquely and helps to store your projects in version control tools
6.  In Normal Project, if you want to work on any third party / API applications then you have to associate those jar files and associate/configure those jar files to your project manually, whereas in Maven project provide the third party/API applications dependency in POM file and then click on Maven install then automatically those respective libraries automatically to your project.

Example: Selenium java dependency, should add the below one in your POM file and run Maven install to have them to your project

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
<scope>test</scope>
</dependency>


Example: Cucumber maven dependency

<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>

Steps involved in creating a Maven project

1.       Select File>>New >> Project

2.       Select Maven and click Next on New Project Window

3.       Provide inputs against
a.       Group ID
b.      Artifact ID
c.       Version and click Next

4.       Provide inputs to
a.       Project Name
b.      Project Location and click Finish

5.       Finally, a Maven project will be created with a POM file. 

Note: Here the project folder will be automatically created along with the default details related to Maven and the project in the POM file.

Now it is the phase where you add the 3rd party applications/API related Maven dependency in the POM file and just click on the install under Maven Life Cycle to have the respective libraries to your project.




Monday, March 4, 2019

VB script to Interact with Application Program Interfaces (API's) - CreateObject



The CreateObject function is used to create an object of the type specified in the argument. The Set statement assigns the object reference to a variable or property

Syntax:

CreateObject(ServerName.TypeName, [RemoteServerName])   ‘2nd argument is optional

Here with providing the list of API you can work with

  1.  Excel Sheet
  2. Word document
    1. New Document
    2. Existing Document
    3. Convert file format from document to pdf or browser or excel
  3. Internet Explorer
  4. Run Command
    1. Open Temp folder
    2. Open Remote Desktop Connection
  5. Trigger an event on Remote Machines
  6. File system Management
    1. Windows Explorer
  7. Dictionary
  8. Regular Expressions
  9. SQL Database connection
  10. Outlook Mails
  11. Network
  12. Unified Functional Testing (UFT) / QTP Tool
  13. Application LifeCycle Management (ALM)

Examples


1. Working with Excel



Dim tmpExcelApp, tmpWorkbook, tmpSheet
Set tmpExcelApp = CreateObject("Excel.Application")
tmpExcelApp.Visible = true
Set tmpWorkbook = tmpExcelApp.WorkBooks.Add
Set tmpSheet = tmpExcelApp.Sheets(1)

tmpSheet.Cells(1, 1) = tmpWorkbook.Sheets.Count
tmpSheet.Cells(1, 2) = 34
tmpSheet.Cells(2, 1) = Now()

tmpSheet.SaveAs "C:\VasuChiluveru.xls"
tmpExcelApp.Quit

2. Working with Word Document

1. Open any existing document

Set tmpWord = CreateObject("Word.Application")
tmpWord.Visible = True
tmpWord.Documents.Open("D:\VasuChiluveru.doc")

2. Writing some text in and saving the new document

Dim tmpWord
Set tmpWord = CreateObject("Word.Application")
tmpWord.Documents.Add
tmpWord.Selection.TypeText "Hello Friend!!! This document is Audo generated by QTP. "
tmpWord.Selection.TypeText "To know more about Automation view the Blog https://testautomation-by-vasuchiluveru.blogspot.com/"
tmpWord.ActiveDocument.SaveAs "D:\VasuChiluveru.doc"
tmpWord.Quit
Set tmpWord = Nothing

3. Appending a new text in the existing document

Dim tmpWord
Set tmpWord = CreateObject("Word.Application")
tmpWord.Documents.Open "D:\VasuChiluveru.doc"
tmpWord.Selection.TypeText "This new text is append by opening the existing document"
tmpWord.ActiveDocument.Save
tmpWord.Quit
Set tmpWord = Nothing

4. Covert any existing document to PDF or HTML (browser) or Excel. NOTE: change the tmpFormat according to your desire

Dim fso, tmpFile, tmpFilePath, myFile, tmpFormat
Set fso = CreateObject( "Scripting.FileSystemObject")
Set tmpFile = fso.GetFile("D:\VasuChiluveru.doc")

tmpFilePath = tmpFile.Path
tmpFormat = "XLS"
Dim tmpWord
Set tmpWord = CreateObject("Word.Application")
tmpWord.Documents.Open tmpFilePath

If ucase(tmpFormat) = "PDF" Then
myFile = fso.BuildPath (tmpfile.ParentFolder ,fso.GetBaseName(tmpfile) & ".pdf")
tmpWord.Activedocument.Saveas myfile, 17
elseIf ucase(tmpFormat) = "HTML" Then
myFile = fso.BuildPath (tmpfile.ParentFolder ,fso.GetBaseName(tmpfile) & ".html")
tmpWord.Activedocument.Saveas myfile, 8
elseIf ucase(tmpFormat) = "XLS" Then
myFile = fso.BuildPath (tmpfile.ParentFolder ,fso.GetBaseName(tmpfile) & ".xls")
tmpWord.Activedocument.Saveas myfile, 9
End If

tmpWord.Quit

Set tmpWord = Nothing
Set fso = Nothing
Set tmpFile = Nothing

3. Working with Internet Explorer

Dim tmpIE
Set tmpIE = CreateObject("InternetExplorer.Application")
tmpIE.Visible = true
tmpIE.Navigate "https://testautomation-by-vasuchiluveru.blogspot.com/"

4. Working with Run command

1. Open a temporary folder

Set objShell = CreateObject("Wscript.Shell")
objShell.run("%temp%")

2. Open a Remote Desktop Connection

Set objShell = CreateObject("Wscript.Shell")
objShell.run("mstsc")

3. Open a DOS command Prompt/Window

Set objShell = CreateObject("Wscript.Shell")
objShell.run("mstsc")


5. Create a WshController object to run scripts on a remote machine

strServer = "machine_name"
strScript = "script_name.vbs"

Set objWshController =CreateObject("WshController")
Set objRemoteScript = objWshController.CreateScript(strScript, strServer)
objRemoteScript.Execute


6. Working with File system Management

Set fso = CreateObject("Scripting.FileSystemObject")

if fso.FolderExists("D:\Vasu Chiluveru") then
  Msgbox "Found the folder name"
end if

set files = fso.GetFolder("D:\").Files
Msgbox "Total folder names count "&files.count

7. Working on Dictionary

Set d = CreateObject("Scripting.Dictionary")

d.Add "a", "Apple"   
d.Add "b", "BlueTooth"
d.Add "c", "C++"
        
msgbox "Total Count"&d.Count
         
If d.Exists("c") Then
     msgbox  "Specified key exists. The Item Name is = "&d.Item("c")
Else
     msgbox  "Specified key doesn't exist."
End If


8. Working on Regular Expressions

' The character 'i' is replaced for the first found 'i' by '$' 

txt="This is a beautiful blossam day"

Set objReg=CreateObject("vbscript.regexp")
objReg.Pattern="i"

msgbox objReg.Replace(txt,"$")


9. Working on Oracle/SQL database

Set connDB = createobject(“ADODB.Connection”) 
Set recrdSet = createobject(“ADODB.RecordSet”) 

Dim dbquery        
Dbquery=”Select * from TableName”  
connDB.Open“Provider=SQLQLEDB;Server=.\SQLEXPRESS;UserId=userid;Password=password;Database =DatabaseName”        
recrdSet.Open dbquery,obj     

val1 = recrdSet.fields.item(0)
val2 = recrdSet.fields.item(1)
val3 = recrdSet.fields.item(2)

msgbox “Value 1 = “&val1&“Value 2 = “  & val2 & “Value 3 = “& val3
                    
connDB.close                              
recrdSet.close  

Set connDB =Nothing              
Set recrdSet =Nothing


10. Working with Outlook Mails

Set tmpOutlook = CreateObject("Outlook.Application")
Set tmpNameSpace = tmpOutlook.GetNamespace("MAPI")
Set myMail = tmpOutlook.CreateItem(0)

myMail.To = "Mention recipient mail id"
myMail.Subject = "Welcome .... Blog created by Vasu Chiluveru"
myMail.Body= "To know more on Automation Visit the URL https://testautomation-by-vasuchiluveru.blogspot.com/"

myMail.Send

Set myMail = Nothing
Set tmpOutlook = Nothing
Set tmpNameSpace = Nothing 


11. Working with Network Systems

'Retrieve My Computer name or system name
Set tmpNetwork = CreateObject("Wscript.Network")
tmpComputerName = tmpNetwork.ComputerName
msgbox tmpComputerName

12. Unified Functional Testing (UFT) / QTP Tool

'Open QTP and open and Run the Test script & then close the Tool

Dim tmpObj, tmpTest
Set 
tmpObj=CreateObject("QuickTest.Application")

'Check if the QTP tool is not already Launched
If Not 
tmpObj.Launched then    tmpObj.Launch
end if
tmpObj.Visible=TruetmpObj.Open "Provide the path of the QTP script"
Set 
tmpTest=tmpObj.Test
'Run the Test
tmpTest.Run 
'Close the Test
tmpTest.Close 
'Quit the QTP Application
tmpObj.Quit 


13. Application LifeCycle Management (ALM)

'Get the folders from the given folder (TEST PLAN)

Set tdc = CreateObject("TDApiOle80.TDConnection")
tdc.InitConnectionEx "https://qcURL:8080/qcbin"
tdc.Login "userID", "PWD"
tdc.Connect "DOMAIN", "ProjectName"

Set sfolder = tdc.TreeManager.TreeRoot("Subject")
msgbox sfolder.Count

For i = 1 To sfolder.Count
   msgbox sfolder.Child(i).name
Next