Tuesday, May 7, 2013

Close all browsers


Public Function func_closeBrowsers()

 Dim oBrowser 'to store browser object description

 'Create description object
 Set strOpenBrowser = Description.Create
 strOpenBrowser("creationtime").Value = 0
 
 'close all open browsers
 While Browser(strOpenBrowser).Exist(0)
    Browser(strOpenBrowser).Close
 Wend
 
 'verify  whether all the opened browsers are closed or not.
 If Browser(strOpenBrowser).Exist(0) = False Then
  func_closeBrowsers = True
  sub_reportSuccess "Close Browser", "All browsers are closed successfully"
 Else
  func_closeBrowsers = False
 End If
End Function 'End of 'closeBrowsers' function.


Set browser options

Public Sub sub_SetBrowserOptions()
  Dim objShell         'To store shell object
  Dim RegInvalidSiteCert    'To store registry key value for "warn about certificate address mismatch" option.
  Dim RegChangeBtwSecure  'To store registry key value for "warn if changing between secure and not secure mode" option.
  Dim RegAllowActiveContent 'To store registry key value for "Allow Active content to run in files on MyComputer" option.
  Dim RegDispMixedContent  'To store registry key value for "Display Mixed Content" option.
  
 'set the shell object reference.
 Set objShell = CreateObject("WScript.Shell")
 
 'to run next step when error occurred.
 On Error Resume Next
 
 'to capture "warn about certificate address mismatch" option path in Registry Editor.
 RegInvalidSiteCert = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WarnonBadCertRecving"
 
 'to capture "warn if changing between secure and not secure mode" option path in Registry Editor.
 RegChangeBtwSecure = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WarnOnZoneCrossing"
 
 'to capture "Allow Active content to run in files on MyComputer" option path in Registry Editor.
 RegAllowActiveContent = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_LOCALMACHINE_LOCKDOWN\iexplore.exe"
 
 'to capture "Display Mixed Content" option path in Registry Editor.
 RegDispMixedContent = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1609"
 
 'Uncheck "warn about certificate address mismatch" option
 objShell.RegWrite RegInvalidSiteCert,"0","REG_DWORD"
 
 'Uncheck "warn if changing between secure and not secure mode" option
 objShell.RegWrite RegChangeBtwSecure,"0","REG_DWORD"
 
 'Uncheck "Allow Active content to run in files on MyComputer" option.
 objShell.RegWrite RegAllowActiveContent,"0","REG_DWORD"
 
 'Uncheck "Display Mixed Content" option.
 objShell.RegWrite RegDispMixedContent,"0","REG_DWORD"
 
 'WScript.Quit 'To stop and exit from the script.
 
End Sub 'End of 'SetBrowserOptions' function.


Monday, May 6, 2013

Remove an attachment from QC Through QTP

Function RemoveAttachFromQC(File_Name)
    var_cnt= QCUtil.CurrentTest.Attachments.NewList(“”).count
    For i= 1 to var_cnt
        If   QCUtil.CurrentTest.Attachments.NewList(“”).Item(2).Name =File_Name Then
            Attachment = QCUtil.CurrentTest.Attachments.NewList(“”).Item(1).ID
           QCUtil.CurrentTest.Attachments.RemoveItem(Attachment)
        Else
           Reporter.ReportEvent micFail,"Delete failed","Please provide the valid filename with extention"
        End If
    Next
End Function

File_Name=”Test.txt” 

Call RemoveAttachFromQC(File_Name)

Upload a file as Attachments To QC

Function UpLoadAttachToQC(File_Path)
    Set ObjCurrentTest = QCUtil.CurrentTest.Attachments
    Set ObjAttch = ObjCurrentTest.AddItem(Null)
    ObjAttch.FileName = File_Path
    ObjAttch.Type = 1
    ObjAttch.Post
    ObjAttch.Refresh
End Function
 

File_Path=”D:\test.txt”
 

Call UpLoadAttachToQC(File_Path)

Wednesday, April 24, 2013

Check spelling error for links in a page

The below code will retrieve all the links in the specific page and adds them to microsoft word and then check for the spelling errors

Dim Desc
Set mw=CreateObject(“Word.Application”)     '‘Creating the Word object
Set Desc=Description.Create  '`Creating the properties collection object
Desc("micclass").value="Link" 'Entering Properties information into object
Set TotLinks=Browser("Browsername").Page("Pagename").ChildObjects(Desc)          'retrieving the link names through child objects on page
For (i=0 to TotLinks.count-1)
    mw.WordBasic.filenew                  'To open new word basic file
    LinkName=TotLinks(i).GetROProperty(“name”)                         'Taking the name property of every individual object
    mw.WordBasic.insert LinkName & " "
    if mw.ActiveDocument.Spellingerrors.count>0 then
        Reporter.Reportevent micFail, "Spelling mistake","Link name:" & LinkName               
    End if
    mw.ActiveDocument.Close(False)
next
mw.quit

Tuesday, April 23, 2013

Handling alert in Selenium RC


package com.softwaretesting_guru.help;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestCase;


public class AlertTest extends SeleneseTestCase {
      SeleniumServer ss;

      @Before
      public void setUp() throws Exception {
            // Start Selenium Server
            SeleniumServer ss = new SeleniumServer();
            ss.start();
            // Start Selenium
            selenium = new DefaultSelenium("localhost", 4444, "firefox",
                        "https://irctc.co.in");
            selenium.start();

      }

      @After
      public void tearDown() throws Exception {

      }

      @Test
      public void test() throws InterruptedException {
            // open the browser
            selenium.open("/");
            // maxmize the browser
            selenium.windowMaximize();
            // click on login button
            selenium.click("id=button");
            // expected result user should get alert using selenium verify alert and
            // handel the alert
            // verifying the alert
            if (selenium.isAlertPresent()) { // handel the alert
                  selenium.getAlert();
                  System.out.println("Alert Present");

            } else {
                  System.out.println("There is no alert present test case fail");
            }
            // enter username
            selenium.type("name=userName", "selenium");
            // enter password
            selenium.type("name=password", "selenium");

            Thread.sleep(5000);
            // getting the alert text use below code
            // Store the alert text
            String str = selenium.getAlert();
            // print alert text
            System.out.println(str);
            // compare the str text and alert text
            String alert = "Enter Value for  UserName";
            if (alert.equals(str)) {
                  // handel alert
                  System.out.println("Alert Present");

            } else {
                  System.out.println("There is no alert");
            }

            Thread.sleep(5000);
      }

}
 
By: Manoj Kumar

                                

Agile methodology

What Is Agile?

Agile methodology is driven by face to face communication than written documents. It is an alternative to waterfall model but in incremental manner. The daily tasks are divided into small increments called sprints with minimum planning that don’t include long term planning. The collection of sprints is called product backlog. These are iteration which last from one to four weeks. Each iteration would include planning, requirement analysis, design, coding  and testing. So, at the end of each iteration, a working product will be in a position to be demonstrated to the stake holders. The face to face meetings will be held in the first hour of the day before the team starts their work. These meetings are termed as Scrum meetings and will not last more than 15 minutes. These are also termed as stand up meetings.

Burn down charts are drawn and will display the progress.

Scrum team has only three roles: Product Owner, Team, and Scrum Master.

Product Owner: The Product Owner represents the stakeholders and are accountable for team deliverables.

Development Team: The development team is the core team that develops the planned sprints from the product backlog.

Scrum Master: Scrum is facilitated by a ScrumMaster. The ScrumMaster ensures that the Scrum process is used as intended. The ScrumMaster enforces all rules that would be followed by the team.

Advantages:

1.    Agile Methodology helps in saving Time and Money.
2.    Great transparency as whole team will be involved on regular basis
3.    Less documentation that will help in concentrating on the product than the documentation
4.    Issues can be quickly tracked and closed due to daily meetings
5.    Change requests can be implemented as the feedback will be collected for every sprint

AI in Software Testing: How Artificial Intelligence Is Transforming QA

For years, software testing has lived under pressure: more features, faster releases, fewer bugs, smaller teams. Traditional QA has done her...