Thursday 31 October 2013

Working with Regular Expression (RegExp) Object in QTP

Function 

Function FindPatternMatches(str,pat)
Set regEx = New RegExp
regEx.pattern=pat
regEx.ignorecase=true
regEx.global=true

msgbox "Patterne found-"&regEx.test(str)
Set matches=regEx.execute(str)
msgbox "Total Matchec found-"&matches.count
For i = 0 To matches.count-1
Set match=matches(i)
msgbox "Value found at index-"&match.firstindex&"..Match value---"&match.value
Next

End Function

Examples

s="Welcome Sudhakar you have 88 Unread Mails"
p="[a-zA-Z0-9]+"
p="^Welcome[a-zA-Z]+[.]\s you have[0-9]+Unread Mails[.]"
p="([a-zA-Z]+)([.])|([0-9]+)"
FindPatternMatches s,p


s="HCQ9D-TVCWX-X9QR1-J4B2Y-2GR2T"
p="[A-Z0-9]{5}-{0,1}"
FindPatternMatches s,p


s="Email id is mg_sudha06@yahoo.co.in or mgsudha09@rediffmail.com or sudhakar8871@gmail.com"
p="[a-zA-Z0-9]{3,}@[a-zA-Z]{1,}[.][a-zA-Z]{1,}"
FindPatternMatches s,p


s="dates are 21/01/2012 01/11/2013 01/01/2014 23/01/2014"
p="((0[0-9])|(1[0-9])|(2[0-9])|(3[0-9]))/((0[1-9])|(1[0-2]))/[0-9]{4}"

FindPatternMatches s,p

***********************************************************************************

Monday 28 October 2013

Working with DotNetFactory in QTP!!!!

'create the .net screen
Set screen=DotNetFactory("System.Windows.Forms.Screen")

Set allscreens=screen.AllScreens

'msgbox "Total Availble screens---"& allscreens.length
'Get the enumerator for current array
Set enumScreen=allscreens.GetEnumerator()

While enumScreen.Movenext
Set oscreen=enumScreen.current
msgbox "Device Name--"+oscreen.devicename
msgbox "Bound---"&oscreen.Bounds.tostring()
msgbox "Type---"&oscreen.gettype().tostring()
msgbox "Working Area---"&oscreen.workingarea.tostring()
msgbox "Primary Screen---"&oscreen.primary.tostring()
msgbox vbnewline
Wend

**********************************************************************************
'Create .net audio object
Set obj=DotNetFactory("Microsoft.VisualBasic.Devices.Audio","Microsoft.VisualBasic")
'play the wav file
obj.play "C:\WINDOWS\Media\Windows XP Shutdown.wav"
set obj=nothing

Handling Java script..in Selenium

import static org.junit.Assert.*;

import java.util.Arrays;
import java.util.List;

import org.junit.Test;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;


public class check_box {

@SuppressWarnings("unchecked")
@Test
public void testDefaultSelectedCheckbox() {

WebDriver driver=new FirefoxDriver();
driver.get("http://dl.dropbox.com/u/55228056/Locators.html");
//Expected list of selected Checkbox
List<String> checked = Arrays.asList(new
String[]{"user1_admin", "user3_browser"});
//Create an instance of JavaScript Executor from driver
JavascriptExecutor js = (JavascriptExecutor) driver;
//Locate all the Checkbox which are checked by calling jQuery
//find() method.
//find() method returns elements in array
List<WebElement> elements = (List<WebElement>)
js.executeScript("return jQuery.find(':checked')");
//Verify two Checkbox are selected

assertEquals(elements.size(),2);
//Verify correct Checkbox are selected
for (WebElement element : elements)
assertTrue(checked.contains(element.getAttribute("id")));
driver.close();



}

}

Sunday 27 October 2013

What is the difference between RD and REQM?

Requirements Management, or "REQM," is all about maintaining the set of requirements that you have, and the process of accepting new ones. In the CMMI world, that includes understanding them, committing to them, managing changes to them, maintaining the appropriate degree of traceability, and understanding how they relate to the actual work being performed by the team.

Requirement Development, or "RD," is about the transformation of customer needs into requirements that can then evolve into a design and/or code. This includes eliciting the customer needs (JAD sessions, interviews, et al), transforming those needs into requirements, evolving them into product requirements, allocating the requirements across releases, teams, developers, or modules, validating them, and ensuring that they fit within the customer constraints and assumptions.

I am not aware of one single tool that does all of this, but parts can be supported by Borland's CaliberRM, IBM's ReqPro, or Doors. My preference is CaliberRM, but they all pretty much do the same thing. They are also all parts of a larger "development framework" that these companies market.