QTP Script To Count Number Of Buttons In a Webpage-QTP Scripts-QTP Script To Count Number Of Checkboxes In a Webpage

Script to count no. of buttons in a webpage in Quick Test Professional(QTP).

Check here for QTP Script to count no. of checkboxes in a webpage.

Ex 1:

SystemUtil.Run"www.google.com"
Set g=Browser("name:=Google").Page("title:=Google")
Set aa=description.Create
aa("html tag").value="INPUT"
aa("type").value="submit"
Set bb=g.childobjects(aa)
cc=bb.count
msgbox "number of buttons in a webpage=" & cc


Ex 2:

SystemUtil.Run"www.yahoomail.com"
Set g=Browser("name:=Yahoo! Mail: The best web-based email!").Page("title:=Yahoo! Mail: The best web-based email!")
Set aa=description.Create
aa("html tag").value="INPUT"
aa("type").value="submit"
Set bb=g.childobjects(aa)
msgbox "number of buttons in a webpage=" & bb.count

Check here for QTP Script to count no. of checkboxes in a webpage.
SQL Queries Collection
Movie Songs Lyrics
VB Script to insert values into database table in QTP
QTP Script to delete a particular row in an excelsheet.

QTP Script to Insert Values Into Database Table-Script for Inserting values in database table in QTP

VBScript to insert values in database table.

We have table "EMP" in database "db"(Microsoft Access).

EMP Table has following data in it.


EMPNO EMPNAME EMPSAL
1 Lakshmi 30000
2 Laxmi 25000
3 Latha 15000

Check This Blog For SQL Queries

Check this post for Script to get column names from database table(MS Access).


Dim con,rs

set con= CreateObject( "ADODB.Connection")

set rs =CreateObject("ADODB.Recordset")

con.provider="microsoft.jet.oledb.4.0"

con.open"d:\db.mdb"

rs.open "insert into EMP(empno,empname,empsal) values(4,'Lakshmi',40000)",con

msgbox("Inserted")

Above script(code)will insert values in database table.


Output:

EMPNO EMPNAME EMPSAL
1 Lakshmi 30000
2 Laxmi 25000
3 Latha 15000
4 Lakshmi 40000


QTP Script to count no. of checkboxes in a webpage
SQL Queries Collection
QTP Script for Connecting to database
QTP Script to export database data to excel sheet
QTP Script to import database data to datatable
Connecting to MSAcess,Oracle,SQL Server Database
Hindi and Telugu Songs Lyrics
QTP Script to get column names from database table(MS Access).

QTP Script to Delete Database Data-Deleting Database Table Data Through QTP

VBScript to delete a single row in database table.

We have table "EMP" in database "db"(Microsoft Access).

EMP Table has following data in it.


EMPNO EMPNAME EMPSAL
1 Lakshmi 30000
2 Laxmi 25000
3 Latha 15000

Check This Blog For SQL Queries

Check this post for Script to get column names from database table(MS Access).

Dim con,rs

set con= CreateObject( "ADODB.Connection")

set rs =CreateObject("ADODB.Recordset")

con.provider="microsoft.jet.oledb.4.0"

con.open"d:\db.mdb"

rs.open "delete from EMP where empsal=15000 ",con

msgbox("Deleted")

Above script(code)will delete a row in database table(empsal=15000).

Output:

EMPNO EMPNAME EMPSAL
1 Lakshmi 30000
2 Laxmi 25000


To Delete all rows in database table just modify sql query as shown below

rs.open "delete from EMP where empsal=15000 ",con

Replace with

rs.open "delete from EMP ",con in the above code and the output will be

Output:

EMPNO EMPNAME EMPSAL


QTP Script to count no. of checkboxes in a webpage
SQL Queries Collection
QTP Script for Connecting to database
QTP Script to export database data to excel sheet
QTP Script to import database data to datatable
Connecting to MSAcess,Oracle,SQL Server Database
Hindi and Telugu Songs Lyrics
QTP Script to get column names from database table(MS Access).

QTP Script to Update Database Data-Updating Database Table Data Through QTP

VBScript to update data in database table.

We have table "EMP" in database "db"(Microsoft Access).

EMP Table has following data in it.


EMPNO EMPNAME EMPSAL
1 Lakshmi 30000
2 Laxmi 25000
3 Latha 15000

Check This Blog For SQL Queries

Check this post for Script to get column names from database table(MS Access).

Dim con,rs

set con= CreateObject( "ADODB.Connection")

set rs =CreateObject("ADODB.Recordset")

con.provider="microsoft.jet.oledb.4.0"

con.open"d:\db.mdb"

rs.open "update EMP set EMPSAL=50000 ",con

msgbox("Updated")


Above script(code)will update database table(EMPSAL=50000).

Output:

EMPNO EMPNAME EMPSAL
1 Lakshmi 50000
2 Laxmi 50000
3 Latha 50000


QTP Script to count no. of checkboxes in a webpage
SQL Queries Collection
QTP Script for Connecting to database
QTP Script to export database data to excel sheet
QTP Script to import database data to datatable
Connecting to MSAcess,Oracle,SQL Server Database
Hindi and Telugu Songs Lyrics
QTP Script to get column names from database table(MS Access).

VBScript to Delete a Particular row in an EXCELSHEET :QTP Scripting

QTP Script to delete a specific row in an ExcelSheet.

Check This Script to get Excelsheet row count and column count in QTP

We have Excelsheet with following values

A B C
11 lak QTP
22 lax LR
33 laxmi WR
44 lakshmi QC

Set aa = CreateObject("Excel.Application")
Set bb = aa.Workbooks.Open("C:\es.xls")
Set cc = aa.worksheets("Sheet1")
cc.Rows(1).Delete
bb.Save
aa.Workbooks.Close()

Above script deletes first row of excelsheet.

After running the script excelsheet will have following values.

A B C
22 lax LR
33 laxmi WR
44 lakshmi QC

Similarly to delete 3 row(just replace 1 with 3 in the above script).

Set aa = CreateObject("Excel.Application")
Set bb = aa.Workbooks.Open("C:\es.xls")
Set cc = aa.worksheets("Sheet1")
cc.Rows(3).Delete
bb.Save
aa.Workbooks.Close()

QTP Script to export database data to excel sheet
VBScript to Check Whether Particular File Exists or Not.
Check this Post for Datatable Methods.
Excel Sheet Creation and Writing Data Into It
Data Driven Using Excel Sheet
Data Driven Using Notepad
Movie Songs Lyrics
SQL Queries Collection
Read Specific cell value from excel sheet using VBScript in QTP.

QTP Script to get column count of database table - Quick Test Professional Scripts

VBScript to get number of columns(count)present in database table.

We have table "EMP" in database "db"(Microsoft Access).

EMP Table has following data in it.


EMPNO EMPNAME EMPSAL
1 Lakshmi 30,000
2 Laxmi 25,000
3 Latha 15,000


Check This Blog For SQL Queries

Check this post for Script to get column names from database table(MS Access).


Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
con.provider="microsoft.jet.oledb.4.0"
con.open"d:\db.mdb"
rs.open"select*from EMP",con
column_count=rs.Fields.count
Msgbox column_count

Output:

3

SQL Queries Collection
QTP Script for Connecting to database
QTP Script to export database data to excel sheet
QTP Script to import database data to datatable
Connecting to MSAcess,Oracle,SQL Server Database
Hindi and Telugu Songs Lyrics
QTP Script to get column names from database table(MS Access).

QTP Script to get Excelsheet Rowcount and Columncount

QTP Script To retrieve no.of columns and no.of rows in an excelsheet.


In excelsheet we have values as shown below

A B C
1 aa ll
2 bb aa
3 cc xx
4 dd mm
5 ee ii

Check This Post for Reading Specific cell value from excel sheet using VBScript in QTP

VBScript to get rowcount and columncount.

Set a= CreateObject("Excel.Application")
Set b=a.workbooks.open("d:\es.xls")
Set c=b.worksheets("Sheet1")
column_count= c.usedrange.columns.count
row_count= c.usedrange.rows.count
Msgbox "No.of Columns="&column_count
Msgbox "No.of Rows="&row_count
b.close

Result:

No.of Columns=3
No.of Rows=5

SQL Queries Collection
Movie Songs Lyrics
QTP Script to export database data to excel sheet
VBScript to Check Whether Particular File Exists or Not.
Check this Post for Datatable Methods.
Excel Sheet Creation and Writing Data Into It
Data Driven Using Excel Sheet
Data Driven Using Notepad

To Retrieve Column Names From Database Table in QTP-VBScript To Get Column Names From Table Present in Database

VB Script to get column names from database table(MS Access).

We have table "EMP" in database "db"(Microsoft Access).

EMP Table has following data in it.

EMPNO EMPNAME EMPSAL
1 Lakshmi 30,000
2 Laxmi 25,000
3 Latha 15,000

Check This Blog For SQL Queries

Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
con.provider="microsoft.jet.oledb.4.0"
con.open"d:\db.mdb"
rs.open"select*from EMP",con
For i = 0 To rs.Fields.Count - 1
column_name=rs.Fields(i).Name
Msgbox column_name
Next

Output:

EMPNO
EMPNAME
EMPSAL

SQL Queries Collection
QTP Script for Connecting to database
QTP Script to export database data to excel sheet
QTP Script to import database data to datatable
Connecting to MSAcess,Oracle,SQL Server Database
Hindi and Telugu Songs Lyrics

VBScript to Get Cell Value of Particular Row and Column From ExcelSheet

How to get data from a particular row and a particular column from Excel Sheet in QTP?

Check This Post For Script To Get Cell Value of Particular Row and Column From Datatable in QTP.

QTP Script to get particular cell value from ExcelSheet in the specified row.

Below script is for retrieving 2rd row,2rd column cell value from already existing excelsheet in D drive.

In excelsheet we have values as shown below

A B C
1 aa xx
2 bb yy
3 cc zz

Script to get value "bb" from ExcelSheet is

Set a=createobject("Excel.application")
Set b=a.workbooks.open("D:\es.xls")
Set c=b.worksheets("Sheet1")
d=c.cells(2,2).value
msgbox d
b.close

Similarly to retrieve 3rd row,1column value(3)replace d=c.cells(2,2).value with
d=c.cells(3,1).value in the above script.

SQL Queries Collection
Movie Songs Lyrics

Other QTP Scripts
VBScript to Check Whether Particular File Exists or Not.
Check this Post for Datatable Methods.
Excel Sheet Creation and Writing Data Into It
Data Driven Using Excel Sheet
Data Driven Using Notepad

How To Check Whether Particular File and Folder Exists or Not in QTP?

QTP Script to check whether specified file and folder exist or not.

Data Driven Testing

Datatable Methods

Script to check particular text file exists or not.

Dim f1
Set f1 = CreateObject("Scripting.FileSystemObject")
If (f1.FileExists("D:\lakshmi.txt")) Then
Msgbox "file exists"
Else
Msgbox "file doesn't exist"
End If

FileExists Method:Returns True if a specified file exists,False if it does not.

Syntax:object.FileExists(filespec)

Above script checks text file("lakshmi")in D drive.
If text file is present "file exists" message is displayed else "file doesn't exist" message will be displayed.


Script to check particular folder exists or not.

Dim f1
Set f1 = CreateObject("Scripting.FileSystemObject")
If (f1.FolderExists("C:\laxmi")) Then
Msgbox "folder exists"
Else
Msgbox "folder doesn't exist"
End If

FolderExists Method:Returns True if a specified folder exists,False if it does not.

Syntax:object.FolderExists(folderspec)

Above script checks folder("laxmi")in C drive.
If folder is present "folder exists" message is displayed else "folder doesn't exist" message will be displayed.

SQL Queries Collection
Movie Songs Lyrics
How to Move a File From One Location to Another in QTP?
How to copy a file and folder from one location to other in QTP?
Export Database Data to ExcelSheet

How to Move a File From One Location to Another in QTP?

Script to copy a file and folder from one location to other in QTP


Script for moving a file from One location to Another location in QTP?


Dim f
Set f = CreateObject("Scripting.FileSystemObject")
f.MoveFile "D:\laxmi.txt", "C:\"
Msgbox "File Moved"


Above script is for moving a text file(laxmi)from D drive to C drive.


The MoveFile method takes two parameters,the source file and the destination.


Syntax:object.MoveFile (source,destination)


My Article in Ezine Articles

Data Driven Using Notepad

Script to copy a file and folder from one location to other in QTP

SQL Queries Collection

Movie Songs Lyrics

Manual Testing Faqs

How to Copy a File and Folder From One Location to Other in QTP?

Script for copying a file from One Folder to Another Folder in QTP?

Dim f
Set f = CreateObject("Scripting.FileSystemObject")
f.CopyFile "C:\lakshmi.txt", "D:\"
Msgbox "File Copied"

Above script is for copying a text file(lakshmi)from C drive to D drive.

The CopyFile method,performs the file copy operation.

The CopyFile method takes two parameters,the source file and the destination.

My Article in Ezine Articles

Data Driven Using Notepad

Script to Create Text File

Script to Delete File

Script to Copy a folder from one drive to other in QTP.

Dim f
Set f = CreateObject("Scripting.FileSystemObject")
f.CopyFolder "D:\Test2", "C:\"
Msgbox "Folder Copied"

Above script is for copying a Folder(Test2)from D drive to C drive.

The CopyFolder method,performs the folder copy operation.

The CopyFolder method takes two parameters,the source folder and the destination


QTP Script to Get Names of Subfolders in a Folder.

SQL Queries Collection

Movie Songs Lyrics

Script to Create Folder

My Article in Ezine Articles

My Article got published in Ezine Articles.


Check My First Article in EzineArticles.Com.


I WISH U ALL A VERY HAPPY AND PROSPEROUS NEW YEAR !!!



Software Testing Faqs


Data Driven Testing in QTP

Datatable Methods

QTP Script for different Controls

Script to Capture Tooltip

VBScript Functions With Examples


QTP Script to Check All Checkboxes in a Webpage

Data driven testing using datatable

Related Posts Plugin for WordPress, Blogger...

Fun and Knowledge