ashok kumar


{ City } chennai
< Country > india
* Profession * automation engg. - qtp
User No # 73336
Total Questions Posted # 0
Total Answers Posted # 15

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 65
Users Marked my Answers as Wrong # 18
Questions / { ashok kumar }
Questions Answers Category Views Company eMail




Answers / { ashok kumar }

Question { Zensar, 6213 }

how to click on object?
(with out knowing the object details)
for ex: in a webpage one link is available.i want to click
that link by using one menthod through qtp?


Answer

by using static DP:

Browser("micclass:=Browser").Page("micclass:=page").Link("micclass:=Link").click

by using dynamic DP:

Set objlink = Description.Create()
objlink("micclass").value = "Link"
Set link1 =
Browser("micclass:=Browser").Page("micclass:=Page").ChildObjects(objlink)
msgbox link1.count

Is This Answer Correct ?    6 Yes 4 No

Question { 3051 }

There r 1000 rows and 1000 coloums , in that I want pickup a
name of the coloumn , pls dont say in sql statements , in
interview one of the interviewer said it was a wrong answer
pls any send me answer its urgent


Answer

src = "DRIVER=SQL Server;SERVER= server>;UID=;PWD=;DATABASE="
Set dbconn = CreateObject("ADODB.Connection")
dbconn.Open src
Set dbrecset = dbconn.Execute(query to connect table)
For i = 0 to dbrecset.Fields.Count-1 'to get total col. count

Print dbrecset.Fields(i).Name 'to print col. name

Next

Is This Answer Correct ?    1 Yes 3 No


Question { 5135 }

Hi...
Can anybody help me to write the vbscript for this
question..!!! Am having a string "HELLO WORLD", i want to
find how many "L"s are there.....?????

--> HANEEF <--


Answer

str = "HELLO WORLD"
Set regex = New RegExp
regex.pattern = "L"
regex.Global = True
Set matches = regex.Execute(str)
msgbox matches.count

Is This Answer Correct ?    10 Yes 0 No

Question { 4126 }

Hi..friends can anybody write the script for this question...
Am having some 20 nos of links in a web application, i want
to click some 5,13 & 17th links. So please....can anybody
give the answer....???

-->Hani<--


Answer

Set obj_Link = Description.Create()
obj_Link("micclass").value = "Link"
Set it_Link =
Browser("micclass:=Browser").Page("micclass:=Page").ChildObjects(obj_Link)
For i = 0 to it_Link.count-1 step 2

it_Link(i).Click 'it click +2,4,6....

Next

Is This Answer Correct ?    5 Yes 1 No

Question { 4447 }

can any one tell me what is syntax error in line

msgexist=Browser("title:=Gmail: Email.*").Page(
"title:=Gmail: Email .*").WebElement(innertext=&msg).exist


'code **************

Call login("lal="," " )
wait(5)
Call errormsg("Invalid email address. [?]" )

Function errormsg(msg)
msgexist=Browser("title:=Gmail: Email.*").Page(
"title:=Gmail: Email .*").WebElement(innertext=&msg).exist
if msgexist then

Reporter.ReportEvent micPass,"enter valid username or pwd
",msg
else
Reporter.ReportEvent micFail, "entered valid uname and
pwd",msg
end if

End Function


Answer

msgexist=Browser("title:=Gmail: Email.*").Page(
"title:=Gmail: Email .*").WebElement("innertext="&msg).exist

Is This Answer Correct ?    4 Yes 0 No

Question { 13153 }

On a web application I want to select list item 5 from a
dropdown list. but QTP identifying this object as
winobject. Then how can we select list item 5 from that
dropdown list.


Answer

Hi,
1. Are u using IE browser?
2. Have u opened the browser after QTP opened?

If u opened the IE browser after the QTP,

then, object will be record as Weblist, if you want to
select more than one value from list, try "ExtendSelect"

For ex:
Browser(".*").Page(".*").WebList(".*").Select "A"
Browser(".*").Page(".*").WebList(".*").ExtendSelect "B"
Browser(".*").Page(".*").WebList(".*").ExtendSelect "C"

Is This Answer Correct ?    7 Yes 3 No

Question { Wipro, 4967 }

During execution, how can we capture the data from the pop-
up, ie. when any popup comes with some numbers written on
it, then how can we capture the value/number that is coming
on the pop-up and save in the dynamic file/or other file,
even when the run is going on.


Answer

Hi,

Use Getroproperty,
For ex: ivalue =
Browser(".*").Dialog(".*").GetRoProperty("text")
Now, using FSO save the ivalue in required file.

Is This Answer Correct ?    3 Yes 2 No

Question { Impetus, 7349 }

Gmail application is there.On that Inbox so many mails are
there including naukari mails.
On that mails i can select the only naukri mail checkboxes.
plz tell the descriptive code for the above..


Answer

Browser("Micclass:=Browser").Page("Micclass:=Page").WebEdit("name:=Email").Set
""
Browser("Micclass:=Browser").Page("Micclass:=Page").WebEdit("name:=Passwd").Set
""
Browser("Micclass:=Browser").Page("Micclass:=Page").WebButton("name:=Sign
in").Click
Browser("Micclass:=Browser").Sync
rowcount =
Browser("Micclass:=Browser").Page("Micclass:=Page").Frame("html
id:=canvas_frame").WebTable("class:=F cf zt").RowCount
For currentrow = 1 to 10'rowcount

mailsubject =
Browser("Micclass:=Browser").Page("Micclass:=Page").Frame("html
id:=canvas_frame").WebTable("class:=F cf
zt").GetCellData(currentrow,3)
If mailsubject = "Naukri.com" Then

Set oChkbox =
Browser("Micclass:=Browser").Page("Micclass:=Page").Frame("html
id:=canvas_frame").WebTable("class:=F cf
zt").ChildItem(currentrow,1,"WebElement",0)
oChkbox.Click

End If

Next

Is This Answer Correct ?    13 Yes 1 No

Question { 5181 }

I am verifying the actual vs the input value to make sure
that they been entered correctly. In the Global Sheet I have
a column called Customer with the multiple names in each row
and now I am trying to capture the value during runtime
under the column name Customer_in_Apps.

Somewhat it works but during runtime the values are being
stored in each column vs each row i.e., Customer_in_Apps,
Customer_in_Apps1. Automatically it add columns instead of
rows.

row=datatable.getsheet("Global").GetRowCount
for x=1 to row
datatable.getsheet("Global").SetCurrentRow(x)
Window("Customer Desktop").Window("Customer Tracking
(Privacy").WinObject("TreeView20WndClass").Click 92,244
runtimevalue =
.VbTreeView("vbname:=AppServerTree").GetROProperty("Selectio
n")
Val1=Datatable.Value("Customer",dtGlobalSheet)
Val2 = Datatable.GlobalSheet.AddParameter("Customer_in
_Apps",runtimevalue)

If (trim(Val2)=trim(Val1)) Then

Reporter.ReportEvent micPass, "Customer validation
successful", "Actual Value: " &Val1&vbcrlf& "Customer
Value: " &_Val2
else

Reporter.ReportEvent micFail, "Customer validation
unsuccessful", "Actual Value: " &Val1&vbcrlf& "Customer
Value: " &Val2
End If
Next


Answer

Hi,

Here the problem is 'AddParameter' used inside the 'FOR'
loop, when QTP runs it successfully add your column
successfully at first time, when the second iteration
perform QTP will check whether the column name is exist
previously or not, if it exist it append numeric, that so u
got N number of column, for that u need use 'AddParameter'
before the loop, below is modified of ur script:

row=datatable.getsheet("Global").GetRowCount
Datatable.GlobalSheet.AddParameter("Customer_in _Apps","")
For x=1 to row
datatable.getsheet("Global").SetCurrentRow(x)
Window("Customer Desktop").Window("Customer Tracking
(Privacy").WinObject("TreeView20WndClass").Click 92,244
runtimevalue =
.VbTreeView("vbname:=AppServerTree").GetROProperty("Selection")
Val1=Datatable.Value("Customer",dtGlobalSheet)
DataTable.Value("Customer_in _Apps",dtGlobalSheet) =
runtimevalue
Val2 = Datatable.GlobalSheet.AddParameter("Customer_in
_Apps",runtimevalue)
If (trim(runtimevalue)=trim(Val1)) Then
Reporter.ReportEvent micPass, "Customer validation
successful", "Actual Value: " &Val1&vbcrlf& "Customer Value:
" & runtimevalue
else
Reporter.ReportEvent micFail, "Customer validation
unsuccessful", "Actual Value: " &Val1&vbcrlf& "Customer
Value: " & runtimevalue
End If
Next

Hope.. it will be usefully for you...

Is This Answer Correct ?    1 Yes 1 No

Question { 5181 }

I am verifying the actual vs the input value to make sure
that they been entered correctly. In the Global Sheet I have
a column called Customer with the multiple names in each row
and now I am trying to capture the value during runtime
under the column name Customer_in_Apps.

Somewhat it works but during runtime the values are being
stored in each column vs each row i.e., Customer_in_Apps,
Customer_in_Apps1. Automatically it add columns instead of
rows.

row=datatable.getsheet("Global").GetRowCount
for x=1 to row
datatable.getsheet("Global").SetCurrentRow(x)
Window("Customer Desktop").Window("Customer Tracking
(Privacy").WinObject("TreeView20WndClass").Click 92,244
runtimevalue =
.VbTreeView("vbname:=AppServerTree").GetROProperty("Selectio
n")
Val1=Datatable.Value("Customer",dtGlobalSheet)
Val2 = Datatable.GlobalSheet.AddParameter("Customer_in
_Apps",runtimevalue)

If (trim(Val2)=trim(Val1)) Then

Reporter.ReportEvent micPass, "Customer validation
successful", "Actual Value: " &Val1&vbcrlf& "Customer
Value: " &_Val2
else

Reporter.ReportEvent micFail, "Customer validation
unsuccessful", "Actual Value: " &Val1&vbcrlf& "Customer
Value: " &Val2
End If
Next


Answer

What ever man... don't assign the
'Datatable.GlobalSheet.AddParameter("Customer_in _Apps","")'
line inside the 'FOR' loop, better to write this after the
ur variable declaration part.

Is This Answer Correct ?    0 Yes 0 No

Question { 2739 }

how to handle the textboxes where in it should take the sum
like ex:: while posting a question in this site it will for
what is the result of 6+3=__ where in we have to enter
manually 9 and click on submit... but how to handle these
cases in qtp.. can someone plz help me out wid dis...


Answer

...
Values = Trim(Browser("").Page("").WebElement("html
tag:=B").GetROProperty("intertext")) 'Remove extra space
numbers = Split( (Left (values,Len( values)-1)),"+") 'split
two numbers
Browser("").Page("").WebEdit("tqa").Set
CInt(Trim(numbers(0))) + CInt(Trim(numbers(1)))
...

Is This Answer Correct ?    0 Yes 0 No

Question { TCS, 5093 }


In My application, having Copmany Name : Text Box and
click Save button. if i enter a vlue, after run..........it
shows the already exists. so

how to enter random ro mmultiple names names into webedit
box(company Name). without using DATATABLE



THanks
Ramesh


Answer

Chars =
array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z")

For i = 1 to 4

random = Rnd()*26
random_value = random_value & Chars(random)
Companyname = "CompanyName_"&random_value

Next

Result:
CompanyName_s
CompanyName_so
CompanyName_sop
CompanyName_sopi

--------------------------------
If you don't want loop, then remove the 'For' loop and write
'Randomize' below the array...

Is This Answer Correct ?    0 Yes 0 No

Question { 3254 }

when I try to run below script in QTP "totalPages" value is
2. But i am getting error message (Type mismatch:
'totalPages' Line (): "For i=1 to totalPages".)


totalPages=Browser("Name:=User").Page("Title:=User").WebElem
ent("innertext:=of.*").GetROProperty("InnerText")
msgbox totalPages
For i=1 to totalPages
rnum=Browser("Name:=User").Page("Title:=User").WebTa
ble("column names:=User Name;ID;Last Name;First
Name").GetRowWithCellText("store4")
If rnum>0 Then
r=rnum
Exit for
End If
Browser("Name:=User").Page("Title:=User").WebElement
("html tag:=A","x:=471").Click
MsgBox "Exit"
Next


Answer

Hi,
totalPages value is in string, that so u got this error
change to numeric, for that use CInt

example:
totalPages = CInt(Browser("Name:=User").
Page("Title:=User").
WebElement("innertext:=of.*").GetROProperty("InnerText"))

Or

For i=1 to CInt(totalPages)

Regards,
Ashok

Is This Answer Correct ?    2 Yes 0 No

Question { 5506 }

Hi, i want download attached files in test plan area from
QC to local drive in my system using QTP script. Please
help me


Answer

TestResPath = "Subject/BPT/..."
SaveTo = "C:/TestPlan/"
Set qcConn = QCUtil.QCConnection

Set oTestResource = qcConn.TestFactory


Set oTestResourceList = oTestResource.NewList

For i = 1 to oTestResourceList.count
QCTestPath = oTestResourceList.item(i).Path

if instr(1,TestResPath,QCTestPath)> 0 Then
oTestResourceList.DownloadResource saveTo, True
End if

Next 


Set oTestResourceList = Nothing
Set oTestResource = Nothing
Set qcConn = Nothing

Is This Answer Correct ?    1 Yes 0 No

Question { 14937 }

Write a script to print below pattern 5 4 3 2 1 5 4 3 2 5 4 3
5 4 5


Answer

Here....

For i = 1 To 5
For j = 5 To i Step -1
temp = temp & " " & j
Next
MsgBox temp
temp = ""
Next

Is This Answer Correct ?    12 Yes 3 No