qtp script to return specific weekday name-VBScript Weekdayname function-script in qtp to display specific weekday name
1.
declare the variable
2.
use weekdayname( ) function
3.
displaying the day
Ex: - Dim a
a=Weekday Name (1)
Msgbox a
Output-Sunday
a=Weekday Name (1)
Msgbox a
Output-Sunday
Qtp script to return year from specified date-vbscript year function-script in qtp to display year from specified date-scripts in qtp-vbscript
Returns a whole number representing
the year
Dim a
a=Year(Now)
Msgbox a
Output-2011
Dim a
a=Year("June 16, 2020")
Msgbox a
Output-2020
Dim a
a=Year(Now)
Msgbox a
Output-2011
Dim a
a=Year("June 16, 2020")
Msgbox a
Output-2020
qtp script to return second of the minute-vbscript second function-scripts in qtp-VBSCRIPT Functions with examples and outputs
Returns a whole number from 0
to 59
Dim a
a=Second(Now)
Msgbox a
Output-25
Dim a
a=Second(Now)
Msgbox a
Output-25
Descriptive Programming to check all checkboxes in a webpage
script to check all checkboxes in a webpage.
Set a=Description.Create
a("html tag").value="input"
a("type").value="checkbox"
Set b=Browser("name:=").Page("title:=").childobjects(a)
c=b.count
msgbox c
For i=0 to c-1
b(i).set "on"
Next
Set a=Description.Create
a("html tag").value="input"
a("type").value="checkbox"
Set b=Browser("name:=").Page("title:=").childobjects(a)
c=b.count
msgbox c
For i=0 to c-1
b(i).set "on"
Next
Descriptive Programming To Count No. Of Links In A Webpage
SystemUtil.Run "www.funandknowledge.blogspot.com"
Set aa=description.Create
aa("htmltag").value="A"
set bb=Browser("name:=Fun.*").Page("title:=Fun.*").childobjects(aa)
cc=bb.count
msgbox cc
Set aa=description.Create
aa("htmltag").value="A"
set bb=Browser("name:=Fun.*").Page("title:=Fun.*").childobjects(aa)
cc=bb.count
msgbox cc
Descriptive Programming to count and close all open browsers
Script to get count,names of all open browsers and to close
them.
Set b=Description.Create
b("micclass").value="Browser"
Set obj=Desktop.ChildObjects(b)
msgbox obj.count
For i=0 to obj.count-1
c=obj(i).getroproperty("name")
msgbox(c)
obj(i).Close
Next
Set b=Description.Create
b("micclass").value="Browser"
Set obj=Desktop.ChildObjects(b)
msgbox obj.count
For i=0 to obj.count-1
c=obj(i).getroproperty("name")
msgbox(c)
obj(i).Close
Next
QTP Script to write multiplication table
Script to write multiplication table of 5 in notepad.
Set f=createobject("scripting.filesystemobject")
set g=f.createtextfile("d://xyz.txt")
For i=1 to 10
g.writeline i&"*5="&i*5
Next
createtextfile("d://xyz.txt") creates notepad by name "xyz"in D drive
output of this script in notepad will be
(path-d://xyz.txt)
1*5=5
2*5=10
3*5=15
4*5=20
5*5=25
6*5=30
7*5=35
8*5=40
9*5=45
10*5=50
Set f=createobject("scripting.filesystemobject")
set g=f.createtextfile("d://xyz.txt")
For i=1 to 10
g.writeline i&"*5="&i*5
Next
createtextfile("d://xyz.txt") creates notepad by name "xyz"in D drive
output of this script in notepad will be
(path-d://xyz.txt)
1*5=5
2*5=10
3*5=15
4*5=20
5*5=25
6*5=30
7*5=35
8*5=40
9*5=45
10*5=50
D.P for checkbox
Script to check whether
yahoologinpage(www.yahoomail.com)checkbox is checked or not
Set g=Browser("name:=Yahoo.*").Page("title:=Yahoo.*")
Set obj=Description.Create
obj("htmltag").value="Input"
obj("ClassName").value="webcheckbox"
obj("type").value="checkbox"
Set a=g.childobjects(obj)
c=a(0).getroproperty("checked")
msgbox(c)
If c=0 Then
msgbox "checkbox is not checked"
else
msgbox"checkbox is checked"
End If
Set g=Browser("name:=Yahoo.*").Page("title:=Yahoo.*")
Set obj=Description.Create
obj("htmltag").value="Input"
obj("ClassName").value="webcheckbox"
obj("type").value="checkbox"
Set a=g.childobjects(obj)
c=a(0).getroproperty("checked")
msgbox(c)
If c=0 Then
msgbox "checkbox is not checked"
else
msgbox"checkbox is checked"
End If
Descriptive Programming for Yahoo Login Page
SystemUtil.Run"iexplore","http://www.yahoomail.com"
Set g=Browser("name:=Yahoo.*").Page("title:=Yahoo.*")
g.WebEdit("name:=login").Set "aaa"
g.WebEdit("name:=passwd").SetSecure "bbb"
g.WebButton("name:=Sign In").Click
g.Link("name:=Inbox.*",
"html id:=WelcomeInboxFolderLink").Click
g.Link("name:=Sign Out").Click
SystemUtil.Run"iexplore","http://www.yahoomail.com" statement opens yahoo login page
aaa=username
bbb=password
Set g=Browser("name:=Yahoo.*").Page("title:=Yahoo.*")
g.WebEdit("name:=login").Set "aaa"
g.WebEdit("name:=passwd").SetSecure "bbb"
g.WebButton("name:=Sign In").Click
g.Link("name:=Inbox.*",
"html id:=WelcomeInboxFolderLink").Click
g.Link("name:=Sign Out").Click
SystemUtil.Run"iexplore","http://www.yahoomail.com" statement opens yahoo login page
aaa=username
bbb=password
d.p to create folder in system
Descriptive Programming to create folder in System.
Set obj=createobject ("scripting.filesystemobject")
Set notepad=obj.createfolder("d:\\abc")
this script will create a folder named "abc" in "d" drive.
Set obj=createobject ("scripting.filesystemobject")
Set notepad=obj.createfolder("d:\\abc")
this script will create a folder named "abc" in "d" drive.
QTP Script to Get Names of Subfolders in a Folder
Script in QTP to get Collection(names) of Subfolders in a Folder.
Below script is to get Subfolders names in Folder V1
Where Folder V1 is in Fdrive.
Dim a,b, c, d, e
Set a = CreateObject("Scripting.FileSystemObject")
Set b = a.GetFolder("F:\V1")
Set c = b.SubFolders
For Each d in c
e=e&d.name&vbnewline
Next
msgbox e
Below script is to get Subfolders names in Folder V1
Where Folder V1 is in Fdrive.
Dim a,b, c, d, e
Set a = CreateObject("Scripting.FileSystemObject")
Set b = a.GetFolder("F:\V1")
Set c = b.SubFolders
For Each d in c
e=e&d.name&vbnewline
Next
msgbox e
QTP Script to Export Database Data to Excel Sheet
Import data from database to datatable
Script to export database data to excel sheet in qtp.
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
Set ex=createobject("Excel.Application")
Set a=ex.workbooks.open("D:\Lak.xls")
Set b=a.worksheets("sheet1")
i=1
Do While Not rs.EOF
b.cells (i,1).value=rs.fields("empno")
b.cells(i,2).value=rs.fields("empname")
b.cells(i,3).value=rs.fields("empsal")
rs.movenext
i=i+1
Loop
a.save
a.close
Script to export database data to excel sheet in qtp.
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
Set ex=createobject("Excel.Application")
Set a=ex.workbooks.open("D:\Lak.xls")
Set b=a.worksheets("sheet1")
i=1
Do While Not rs.EOF
b.cells (i,1).value=rs.fields("empno")
b.cells(i,2).value=rs.fields("empname")
b.cells(i,3).value=rs.fields("empsal")
rs.movenext
i=i+1
Loop
a.save
a.close
No comments:
Post a Comment