WORKING WITH QTP

TestEveryThinG

Archive for the ‘WEB’ Category

Available Android app of Testeverything Site

Posted by rajivkumarnandvani on July 26, 2016

Hi,

Now you view the TestEverything Site updates on your Android mobile.just download the android app

Please refer the below link to download the apk file of  Teverything Site.

https://drive.google.com/file/d/0B27kZ9NQHijSQnJtc1RYdGVyR2M/view?usp=sharing

Download TesteveryThing APK file
TesteveryThing APK

Posted in Automation, DATABASE, FAQ QTP, Jenkins, JMETER, Miscellaneous, QTP, QTP FAQ, SELENIUM, WEB, WEBDRIVER, WINDOWS | Tagged: , , , | Leave a Comment »

Select the row in WEBTABLE/WEBGRID using QTP/DOM

Posted by rajivkumarnandvani on July 23, 2011

Hi All,

I found that most of time while working with WEBTABLE we need to the select the row based on some criteria by clicking checkbox or radiobutton.For that first we have to find the row which we have to select based on value of that row like text/link inside the row.
Here I am giving an example how to select a row in Webtable by finding the text. Logic I am using here is first i will find the row number from webtable where my searching text is present using GetRowWithCellText method then I will provide the column name/index of webtable where checkbox is present.


In below mentioned example I will select the row where Confirmation Number is “15204
Let’s see

Select Date ConfirmationNumber User Name Organization Name
17-SEP-2008
13761
 SMITH’S LP SUPPLY CO.
24-OCT-2008
13808
 Micro Motion test1
30-OCT-2008
13874
 EMERSON PROCESS MANAGEMENT ASIA PACIFIC PTE LTD
13-JUN-2009
15058
 Spartan Controls Ltd.
08-AUG-2009
15204
 Emerson Process Management

 Click here to get full details…

http://www.flipkart.com/affiliate/displayWidget?affrid=WRID-141998662587146404
http://www.flipkart.com/affiliate/displayWidget?affrid=WRID-141998664278824982
http://www.flipkart.com/affiliate/displayWidget?affrid=WRID-141998667291069023

Posted in QTP, WEB | Tagged: , , | 8 Comments »

Highlight the text on page using the QTP

Posted by rajivkumarnandvani on May 25, 2011

Hi All,

Someone asked me how to highlight the text on page using the QTP. So here I have created a function that will find the text on page and highlight it if finds else not.

REM  ——  Set page object     ———
set objpage = Browser(“BrowserName”).Page(“Pagename”)
call   HighLightTextPresentOnPage(objpage ,”News” )
Function HighLightTextPresentOnPage(byval objpage , byval Textvalue )
On error resume next
REM ——- Create child object description
Set childobj = Description.Create()
childobj(“micclass”).value=”WebElement”
childobj(“html tag”).value=”.*[A-Za-z0-9].*”
childobj(“outertext”).value =Textvalue
REM  ———-Create ALL child object 
set allobj = objpage.ChildObjects(childobj)
 REM here highlight method we will use that is in build in QTP for object
For i=1 to allobj.count-1
    allobj.Item(i).HighLight
Next
           If allobj.count > 0 then
              HighLightTextPresentOnPage = true
           Else
              HighLightTextPresentOnPage = false
           End if
             On Error GoTo 0
End Function

Posted in QTP, WEB | 1 Comment »

How can I access HTML tags directly?

Posted by rajivkumarnandvani on June 3, 2010

QuickTest provides direct access to the browser’s Document Object Model
(DOM) through which you can access the HTML tags directly. Access to the
DOM is performed using the .Object notation.
The test below demonstrates how to iterate over all the tags in a page. The
test then outputs the inner-text of the tags (the text contained between the
tags) to the Test Results using the Reporter object.
‘ Use the on error because not all the elements have inner-text.

On Error Resume Next
Set Doc = Browser(“CNN Interactive”).Page(“CNN Interactive”).Object
‘ Loop through all the objects in the page.
For Each Element In Doc.all
TagName = Element.TagName ‘ Get the tag name.
InnerText = Element.innerText ‘ Get the inner text.
‘ Write the information to the test results.
Reporter.ReportEvent 0, TagName, InnerText
Next

Posted in QTP, WEB | 1 Comment »

Get Browser(iexplore) Count using VB script

Posted by rajivkumarnandvani on November 1, 2009

bcount = Get_ApplicationCount(“iexplore.exe”)

msgbox bcount

Public Function Get_ApplicationCount( byval sApplicationExe)

Dim strComputer

Dim objWMIService

Dim colProcesses

Dim objProcess

strComputer = “.”

Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”)

Set colProcesses = objWMIService.ExecQuery (“Select * from Win32_Process Where Name = ‘”&sApplicationExe&”‘”) Get_ApplicationCount = colProcesses.count

Set objWMIService = Nothing

Set colProcesses=Nothing

End Function

If  bcount >0  Then

set objBrowser = Description.Create()

objBrowser(“micclass”).value =”Browser”

objBrowser(“CreationTime”).value=bcount-1

msgbox Browser(objBrowser).GetROProperty(“title”)

else

msgbox “No internet explorer open”

End If

Posted in QTP, WEB | Tagged: , , , , | Leave a Comment »

Close All Browser Except OLD One QTP VB

Posted by rajivkumarnandvani on May 13, 2009

Hi All,

Some time we required that Only OLD open Browser Window( Only for IE) will remain Open and rest of all shall be closed during QTP scripting. Here is the Function which will close the all open Browser except OLD Open browser (Work only for Internet Explorer using QTP)

Public function fn_CloseAllBrowserRemainingOLD

rem create Browser description object
Set brwsr=Description.Create
brwsr(“micclass”).value=”Browser”
Set obj=Desktop.ChildObjects(brwsr)
browserCount= obj.count
Set obj=nothing
If  browserCount >1  Then
do
Browser(“CreationTime:=1”).Close
Set obj=Desktop.ChildObjects(brwsr)
browserCount= obj.count
Set obj=nothing
loop  until  browserCount =1
End If

End Function

Posted in QTP, WEB | Tagged: , , | 6 Comments »

Work With List Box QTP

Posted by rajivkumarnandvani on May 3, 2009

When we use list box Object in QTP. QTP perform following operation on listbox . like

Browser(“Browser”).Page(“Page”)..WebList(“ListBox”).Select “ListBoxValue”

It select the value from List Box that value must be present in list box otherwise QTP give an error like that

“Cannot identify the specified item of the ListBox object. Confirm that the specified item is included in the object’s item collection.”

So before selection any value in list box Always insure the value you are going to select in list box must be present by use this method/Function

dim objListBox, sValuematch ,bTrue
set objListBox = Browser(“Browser”).Page(“Page”)..WebList(“ListBox”)
sValuematch =”Type Value that need to be check”
bTrue = fn_Valuematch_for_weblistbx(objListBox ,sValuematch )
if bTrue =True then
Browser(“Browser”).Page(“Page”)..WebList(“ListBox”).Select “ListBoxValue”
end if

REM*************************************************************************************************************
REM ” this function Check the value u define match With in WEBListbox or Not if match return true otherwise False
Public Function fn_Valuematch_for_weblistbx(byval m_listboxobject, byval m_valuematch)
”check is m_listboxobject object or not
If IsObject(m_listboxobject ) = true and IsNull(m_valuematch) = false Then
Dim m_Getallfield,m_arAllfield,m_val,m_actual
m_arAllfield = m_listboxobject.GetROProperty(“all items”)
m_arAllfield =Split (m_arAllfield,”;”)
For each element in m_arAllfield
If m_valuematch = element then ‘ compare the text
fn_Valuematch_for_weblistbx=true ” if value match then return true & exit thr loop
exit for
else
fn_Valuematch_for_weblistbx = false
end if
Next
else
print “Error wrong Parameter for function fn_Valuematch_for_listbx”,”Check paramenter value”
End If
End Function
REM*************************************************************************************************************

Posted in QTP, WEB, WINDOWS | Tagged: , , | 21 Comments »

Delete Cookies and Temprary internet files VB QTP

Posted by rajivkumarnandvani on April 17, 2009

rem ********************************

rem delete cookies

call fn_DeletesubFolderAndFiles(“C:\DOCUME~1\%USERNAME%\Cookies”)

rem *********************************

rem rem delete Temporary internet files

call fn_DeletesubFolderAndFiles(“C:\DOCUME~1\%USERNAME%\Locals~1\Tempor~1”)

rem ***********************************

REM *************************************************************************

REM Function fn_DeletesubFolderAndFiles(path)

Rem this Function delete the files & subfolder under the specified path

REM Input spath := Files path or parent Folder path

REM Output(ReturnType) := None

REM Note := IF file Protected then it will not delete without giving Error

REM Created: 17/April/2009 Rajiv Kumar Nandvani ## Changed:MM/DD/YYYY

REM *************************************************************************

Public Function fn_DeletesubFolderAndFiles(spath)

on Error Resume Next

rem Create File System object

set objFileSystem = CreateObject(“Scripting.FileSystemObject“)

rem Create Window Shel object

Set objWshShell = CreateObject(WScript.Shell“)

Rem get Folderpath under which file present

Set objoFolder = objFileSystem.GetFolder(objWshShell.ExpandEnvironmentStrings(spath))

rem get count the files under the folder and loop run for delete the files

For Each oFile In objoFolder.files

On Error Resume Next

objFileSystem.DeleteFile oFile

Err.clear

Next

rem get count the subfolders under the folder and loop run for delete the subfolders

For Each oSubFolder In objoFolder.SubFolders

On Error Resume Next

objFileSystem.DeleteFolder oSubFolder

Err.clear

Next

rem clear the object

set objFileSystem = nothing

set objWshShell = nothing

set objoFolder = nothing

Err.clear

End function

Posted in QTP, WEB | Tagged: , , , , , | Leave a Comment »

Handle popup window QTP VB

Posted by rajivkumarnandvani on April 11, 2009

REM *************************************************************************
REM  Function  fn_GetPopupMessageText() This function Get the lable textmessage from Popup Dialog window  in Browser page
REM  and enter the label text in Result Excel Sheet
REM Note Dialog Window Must be child of  Parent object

REM  Input              := None
REM  Output(ReturnType) := None
REM  Created:    11/April/2009    Rajiv Kumar Nandvani ## Changed:MM/DD/YYYY

REM *************************************************************************

Call fn_GetPopupMessageText()
Public function fn_GetPopupMessageText()
Set objStaticText =Description.Create()
objStaticText(“nativeclass”).value =”Static”
objStaticText(“text”).value =”.*[a-z].*”
Set objWinbutton =Description.Create()
objWinbutton(“micclass”).value =”WinButton”
If Window(“regexpwndtitle:=Windows Internet Explorer”,”regexpwndclass:=IEFrame”).Dialog(“regexpwndtitle:=Windows Internet Explorer”,”regexpwndclass:=#32770″).Exist(2) then
Window(“regexpwndtitle:=Windows Internet Explorer”,”regexpwndclass:=IEFrame”).Dialog(“regexpwndtitle:=Windows Internet Explorer”,”regexpwndclass:=#32770″).Activate
set objStaticText = Window(“regexpwndtitle:=Windows Internet Explorer”,”regexpwndclass:=IEFrame”).Dialog(“regexpwndtitle:=Windows Internet Explorer”,”regexpwndclass:=#32770″).ChildObjects(objStaticText)
For i=0 to objStaticText.count-1
sDescription =objStaticText(i).GetVisibleText(-1,-1,-1,-1)
Next
set objWinbutton = Window(“regexpwndtitle:=Windows Internet Explorer”,”regexpwndclass:=IEFrame”).Dialog(“regexpwndtitle:=Windows Internet Explorer”,”regexpwndclass:=#32770″).ChildObjects(objWinbutton)
For i=0 to objWinbutton.count-1
objWinbutton(i).click
Exit for
Next
fn_GetPopupMessageText = sDescription
End if
End Function

Public function fn_GetPopupMessageText()
Set objStaticText =Description.Create()
objStaticText(“nativeclass”).value =”Static”
objStaticText(“text”).value =”.*[a-z].*”
Set objWinbutton =Description.Create()
objWinbutton(“micclass”).value =”WinButton”
If Browser(“title:=.*(Page).*”).Dialog(“text:=Windows Internet Explorer”,”nativeclass:=#32770″).Exist(2) then
Browser(“title:=.*(Page).*”).Dialog(“text:=Windows Internet Explorer”,”nativeclass:=#32770″).Activate
set objStaticText = Browser(“title:=.*(Page).*”).Dialog(“text:=Windows Internet Explorer”,”nativeclass:=#32770″).ChildObjects(objStaticText)
For i=0 to objStaticText.count-1
sDescription =objStaticText(i).GetVisibleText(-1,-1,-1,-1)
Next
set objWinbutton = Browser(“title:=.*(Page).*”).Dialog(“text:=Windows Internet Explorer”,”nativeclass:=#32770″).ChildObjects(objWinbutton)
For i=0 to objWinbutton.count-1
objWinbutton(i).click
Exit for
Next

fn_GetPopupMessageText = sDescription
End if

End Function

Posted in QTP, WEB, WINDOWS | Tagged: , | 1 Comment »

XML WITH VB

Posted by rajivkumarnandvani on April 10, 2009

sXMLfilepath =”C:\ReadXML.xml”

strQuery = “/ProfilesInfo/Profiles/ProfileInfo/Profile/Fields/Field [Name=’ProfileUri’ or  Name= ‘Age’] /(Name|Value)”

call ReadXMLValueFromStringQuery( sXMLfilepath ,strQuery)

Public Function       ReadXMLValueFromStringQuery(byval sXMLfilepath , byval strQuery)

Set xmlDoc = CreateObject( “Microsoft.XMLDOM” )
xmlDoc.Async = “False”
xmlDoc.Load( sXMLfilepath )
If  xmlDoc.parseError.errorCode<>0 Then
Print “Invalid XMLFile/No file ”
else
‘strQuery = “/ProfilesInfo/Profiles/ProfileInfo/Profile/Fields/Field [Name=’ProfileUri’ or  Name= ‘Age’] /(Name|Value)”
Set colNodes = xmlDoc.selectNodes( strQuery )
If colNodes.length>0 Then
For Each objNode in colNodes
Print  objNode.nodeName & “: ” & objNode.text
Next
else
Print “Nothing Found for this strQuery  =” & strQuery
End If
End If
Set  xmlDoc = nothing
Set  colNodes = nothing
End Function
Set xmlDoc =nothing

Set ElemList =nothing

Set xmlDoc = CreateObject(“Msxml2.DOMDocument”)

xmlDoc.load(“C:\TestData.xml”)

Set ElemList1= xmlDoc.DocumentElement.ChildNodes

For i = 0 to ElemList1.length-1

msgbox ElemList1.item(i).text

next

Set ElemList = xmlDoc.getElementsByTagName(“book”)

filepath = ElemList.item(0).getAttribute(“author”)

MsgBox filepath

Set ElemList = xmlDoc.getElementsByTagName(“title”)

plot = ElemList.item(0).Text

MsgBox plot

Let’s get started.

In your editor, IDE or whatever, type the following code:

Set xmlDoc = CreateObject( "Microsoft.XMLDOM" )
xmlDoc.Async = "False"
xmlDoc.Load( "dvdcoll.xml" )

If you have an integrated object browser, you’ll probably see a reference to MSXML being inserted.

We’ll start with simple query, display each DVD’s title:

strQuery = "/Collection/DVD/Title"
Set colNodes = xmlDoc.selectNodes( strQuery )
For Each objNode in colNodes
	WScript.Echo objNode.nodeName & ": " & objNode.text
Next

The result will look like this:

Title: Wild Down Under
Title: Pride
Title: Gandhi
Title: The Abyss
Title: Shouf Shouf Habibi

So, why was the query built like this?

<!-- DVD Profiler Version 2.4.0 Collection Export --> <!-- Exported: 22-02-2007 20:13:12 --> <Collection> <DVD>   <ID>014503132125.4</ID>   <UPC>014503-132125</UPC>   <ProfileTimestamp>2006-10-29 10:38:45</ProfileTimestamp>   <Title>Wild Down Under</Title>   <SortTitle>Wild Down Under</SortTitle>

Take a look at the image on the right, a fragment of a screenshot of XML Notepad’s “XSL Output” window with our XML file loaded (or open the XML file in a plain text editor).

What we see is an opening tag <Collection> as the first tag. This translates to /Collection in the query.

Then, between the opening <Collection> and closing </Collection> tags (“inside” the Collection), note the “recordsets” of <DVD> and </DVD> tags. These translate to the DVD part of the query: in the root we find Collections, and inside (or under) Collections we find DVD — just like a directory structure on a disk.

Inside (or under) DVD there are several tags, Title being one of them. So now we have /Collection/DVD/Title.

Note: Queries are case sensitive! Capitalization must match the XML tags exactly.

Now let’s move to the next level of complexity for our queries, display multiple properties:

strQuery = "/Collection/DVD/ ( Title | Genres )"
Note: This is the query definition only. Replace the previous query definition by this new one. The rest of the script remains unaltered.

The part of the query between parentheses is a list of choices, separated by “pipe” characters (|).

Tags will be listed if they match any of these choices, so Title as well as Genres will be shown for each DVD in the collection.

The result will look like this:

Title: Wild Down Under
Genres: Documentary Special Interest
Title: Pride
Genres: Documentary
Title: Gandhi
Genres: Drama Classic
Title: The Abyss
Genres: Science-Fiction Suspense/Thriller
Title: Shouf Shouf Habibi
Genres: Comedy

The genres are listed as single lines, where each line can contain one (or zero) or more genres.

If you look further down in the XML structure, you’ll notice that some keys or tags have subkeys: Genres for example uses Genre subkeys.

Subkeys are used when multiple values are possible. They can be viewed best in XML Notepad’s treeview.

To list each individual genre we must use /Collection/DVD/Genres/Genre.

So next, let’s display the Title and each individual Genre:

strQuery = "/Collection/DVD/ ( Title | Genres/Genre )"

Roughly translated: display anything that matches "/Collection/DVD/Title" or "/Collection/DVD/Genres/Genre"

The result will look like this:

Title: Wild Down Under
Genre: Documentary
Genre: Special Interest
Title: Pride
Genre: Documentary
Title: Gandhi
Genre: Drama
Genre: Classic
Title: The Abyss
Genre: Science-Fiction
Genre: Suspense/Thriller
Title: Shouf Shouf Habibi
Genre: Comedy

Notice how some DVDs have multiple Genres.

OK, listing properties for each item in a collection no longer has any secrets for you.

Let’s select specific items (DVDs) from the collection.

List the titles and genres of all documentaries:

strQuery = "/Collection/DVD [ Genres/Genre = 'Documentary' ] / ( Title | Genres/Genre )"

The result will look like this:

Title: Wild Down Under
Genre: Documentary
Genre: Special Interest
Title: Pride
Genre: Documentary
Title: March of the Penguins
Genre: Documentary
Title: Alaska: Spirit of the Wild
Genre: Documentary
Genre: Special Interest
Title: Wilderness Journey - Canyon Suites
Genre: Documentary
Genre: Special Interest
Genre: Music

It is possible to select based on genre without displaying it:

strQuery = "/Collection/DVD [ Genres/Genre = 'Documentary' ] /Title"

would only display the titles of the documentaries.

Finally, the selection can be narrowed down by using and and or. Note that these are case sensitive, so And will not work.

List titles and all formats for each documentary that supports 16×9 format:

strQuery = "/Collection/DVD " _
         & "[ Genres/Genre = 'Documentary' and Format/Format16X9 = 'True' ] " _
         & "/ ( Title | Format/* )"

The result will look like this:

Title: Wild Down Under
FormatAspectRatio: 1.78
FormatVideoStandard: PAL
FormatLetterBox: True
FormatPanAndScan: False
FormatFullFrame: False
Format16X9: True
FormatDualSided: False
FormatDualLayered: False
FormatFlipper: False
Title: Pride
FormatVideoStandard: PAL
FormatLetterBox: True
FormatPanAndScan: False
FormatFullFrame: True
Format16X9: True
FormatDualSided: False
FormatDualLayered: True
FormatFlipper: False

Posted in QTP, WEB | Tagged: | Leave a Comment »

 
%d bloggers like this: