Friday

Skillset - Test Automation Developer




Note: the Skillset category is just to gauge where you stand in terms of the skills required for the role


Got my hands on another very interesting profile:

The company is seeking an inquisitive, tenacious, and thorough engineer who loves to break things in order to keep us honest about what we’re shipping.

An outstanding Test Automation Engineer believes testing is a collaborative process rather than a confrontation. You get involved with feature development on day one and follow it through release.

You have the team’s trust and the power to say “We can’t ship that.”

Your primary responsibility in this role is simple: ensure we’re shipping the highest quality product we can. To do this you’ll write functional and integration tests and work closely with application engineers to understand what’s going on in the codebase.

In this position you will work with both Selenium and our internal testing framework. We test for performance regressions with jMeter. Your test suites will run under Jenkins as part of our continuous integration system.

In the near future this role will involve native iOS testing and you’ll be a big part of shaping what that looks like.



Wednesday

BPT - Check if a component has failed



As we all know in BPT a test case comprises of many components put together.

Now the best practice would be when a component fails we stop the entire BPT test rather than continue testing, so here is a simple code that will do just that:

Function ComponentFailHandler
     If Reporter.RunStatus = micFail Then ExitTest
End Function  

Can it get easier than this? :P

Tuesday

Copy from excel to word and saveas PDF


Problem : An HR in a startup who had this excel to generate salaries and then convert them into pdf manually. As people increased this became a tedious task.

Solution:  Automation :)

Here is the code that helped me achieve that:

1. Created a button in excel that copies data from the main sheet to the desired format in another sheet.
2. Pick the template to generate pdf
3. Copy the template and open the new word document
4. Copy generated text from excel into the new word document
5. Save as pdf, All set!!


Copy Excel details from one sheet to other -> Copy the text from generated sheet into word template ->
Save the copied word document as PDF


Sub Button1_Click()


Dim LSearchRow As Long
Dim LCopyToRow As Long
Dim wksInput As Worksheet
Dim wksOutput As Worksheet
On Error GoTo Err_Execute

'The wksInput variable will hold a reference to the worksheet
'that needs to be searched
Set wksInput = ThisWorkbook.Worksheets("SalarySheet")
Set gnrt = ThisWorkbook.Worksheets("Payslip")
empname = gnrt.Cells(7, 2)

'Start copying data to row 2 in Sheet2 (row counter variable)
'Loop through all the rows that contain data in the worksheet
'Start search in row 4
For LSearchRow = 2 To wksInput.UsedRange.Rows.Count
'If value in column A = "", copy entire row to wksOutput

If wksInput.Cells(LSearchRow, 1) = empname Then
' One line copy/paste

 wksInput.Cells(LSearchRow, 2).Copy gnrt.Cells(8, 2)
 wksInput.Cells(LSearchRow, 4).Copy gnrt.Cells(11, 2)
 wksInput.Cells(LSearchRow, 5).Copy gnrt.Cells(12, 2)
 wksInput.Cells(LSearchRow, 6).Copy gnrt.Cells(13, 2)

 'Increment the output row
 'LCopyToRow = LCopyToRow + 1
End If
Next LSearchRow

gnrt.Activate
FName = "C:\Salary slip.docx"

'To save the file with this name
SaveDoc = "C:\" & gnrt.Range("B7").Text & "_SalarySlip.pdf"

'CREATE WORD OBJECT
On Error Resume Next
Set wrdApp = CreateObject("Word.Application")

'DISPLAY WORD APPLICATION
On Error Resume Next
wrdApp.Visible = True
wrdApp.Activate

On Error GoTo 0
'OPEN THE (TEMPLATE) FILE
wrdApp.Documents.Open (FName)

'SET A VARIABLE TO REFERENCE ACTIVE DOCUMENT (TEMPLATE)
Set tempDoc = wrdApp.ActiveDocument
'DUPLICATE THE DOCUMENT
wrdApp.Documents.Add wrdApp.ActiveDocument.FullName
'SET A VARIABLE TO REFERENCE THE NEW VERSION OF DOCUMENT
Set mrgDoc = wrdApp.ActiveDocument

'CLOSE THE ORIGINAL (TEMPLATE) VERSION OF DOCUMENT
tempDoc.Close SaveChanges:=False

'ACTIVATE THE NEW DOCUMENT
mrgDoc.Activate
wrdApp.Visible = True

'Copy the data
ThisWorkbook.Sheets("Payslip").Range("a6:c22").Copy
'wrdApp.Selection.PasteExcelTable False, False, False
mrgDoc.Paragraphs(mrgDoc.Paragraphs.Count).Range.InsertParagraphBefore
mrgDoc.Paragraphs(mrgDoc.Paragraphs.Count).Range.Paste
'mrgDoc.SaveAs Filename:=SaveDoc, FileFormat:=wdFormatPDF
mrgDoc.ExportAsFixedFormat SaveDoc, 17, OpenAfterExport:=True

wrdApp.Visible = False
wrdApp.Quit False

Set mrgDoc = Nothing
Set wrdApp = Nothing

MsgBox "All matching data has been copied and pdf generated!"

Exit Sub
Err_Execute:
MsgBox "An error occurred. Number: " & Err.Number & " Description: " & Err.Description
End Sub

Thursday

GWT and QTP - automation!



  • You will need “Add-in Extensibility and Web 2.0 Toolkits” installed along with QTP
    • This will bring in a specific add-in for GWT under web


  • If you are still using QTP 10 then there is a patch that you will need to install for GWT
    • The patches are:
    • Web 2.0 Feature Pack with PreReqs: http://support.openview.hp.com/selfsolv ... t/KM771788
    • Web 2.0 Feature Pack without PreReqs: http://support.openview.hp.com/selfsolv ... t/KM771785
    • Please reconfirm the patches from HP site.
  • By default GWT doesn’t generate the useful web object properties, like “html id” or “name” for object recognition mechanism of GUI test tools
    • It is highly recommended to work with development team to get a unique static values assigned to every web object
  • The objects usually are not unique and are dynamic , Since GWT automation does not support XPaths use HTML DOM.
  • QTP sees all the objects in CSS-based applications, even if objects are hidden
    • To verify that part of HTML page is visible use “Style.display” property
    • If .WebTable().Object.Style.Display = “block” ‘visible
    • if .WebTable().Object.Style.Display = “none” ‘not visible
  • Setting.WebPackage("ReplayType") 
    • use of this technique to get tooltips from GWT objects
  • Right clicks aren’t easy and you will need to execute JavaScript wrappers for this.
  • The last thing would be use as much descriptive programming as possible. Makes life easier!

Sunday

From a QTP to Selenium User - Get Transformed!


There are many tester's who are well versed with QTP but not selenium , here is a quick start - a reference cheat-sheet for Selenium and QTP. The image below has all the basic operations that you would perform on a web browser. The left side are Selenium and the right side are the corresponding QTP commands.

So get ready to get transformed : From QTP to Selenium 

Wednesday

Configure Selenium 2 / Webdriver and TestNG for Eclipse


This is the most common thing that newbie's to selenium struggle with, so here are easy steps  to do the same:


Download Selenium WebDriver jar file from http://seleniumhq.org/download

Download Eclipse (any version should do)

Open Eclipse and create a new Java project
  • Right Click on Left hand side in Eclipse under Package Explorer
  • Select NEW JAVA PROJECT
  • Enter the name of Project and Click on Finish button
Create a New Package
  • Right Click on the New Java Project created → New→ Package
  • Type In a New Package Name and Click on Finish button
Creating a New Java Class file.
  • Right Click on the Newly created Package → New → Class
  • Mark the check box for “public static void main (String args[])”
  • Type In a Class Name and Click on Finish button
Add the Selenium Library files to our project

  • Open Eclipse and Configure Build Path.
Right Click on the package → Build Path → Configure Build Path
  • Click on Libraries tab → Add External Jar’s
  • Add all the jars from the Selenium folder downloaded earlier
  • Expand the Referenced Libraries in the Project Explorer to verify if the jar files are added.
Now initialize the Web Driver object as WebDriver driver=new FirefoxDriver()
  • Mouse over the WebDriver line you will see an Auto complete Option, you will find Import WebDriver.
  • Click on Import WebDriver to see import org.openqa.selenium.firefox.FirefoxDriver;
Also Configure TestNG in Eclipse
  • In Eclipse go to Help → Install New Software
  • Enter http://beust.com/eclipse in the required
  • Check TestNg and then click on Next to follow the Instructions and finally click on Finish
Check if TestNg has been configured in Eclipse
  • Go to Window → Show View → Other
  • Now Select Java and you should see TestNG under that folder.
You are all set to start scripting using Selenium webDriver and TestNG.

Tip: Go to javadocs and copy the link address.

Add this in eclipse by going to configure libraries, select the main selenium jar file, expand and select javadoc, edit the location paste the link and remove index.html

Now everytime you mouseover objects you will have the documentation for the same.




Friday

Six tools for Selenium Object Identification



Six tools that help you with Selenium Object Identification:


1. Firefox – Selenium IDE

2. Firefox – Firebug

3. Firefox – Firepath

4. Google Chrome Developer Tools

5. IE Developer tool bar

6. fire-ie-selenium

Source: Extremely well written post at http://www.joecolantonio.com/