pushkar


{ City }
< Country > india
* Profession *
User No # 117753
Total Questions Posted # 1
Total Answers Posted # 21

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

Users Marked my Answers as Correct # 12
Users Marked my Answers as Wrong # 0
Questions / { pushkar }
Questions Answers Category Views Company eMail

There are 10 rows in the datatable. How can we fetch 2 rows and then skip 3rd row. After that, pick 4th & 5th row and skip 6th row. Please share code

QTP 1176




Answers / { pushkar }

Question { McGraw Hill, 7111 }

When importing an excel file that has several columns each
with different number of rows into QTP's Global datatable,
how can you count the number of rows in a particular column?


Answer

datatable.ImportSheet "C:UserspushkarDesktop123.xls","Sheet1","Action1"
rw=datatable.GetSheet("Action1").GetRowCount
For i=1 to rw
a=datatable.GetSheet("Action1").GetParameter("_11").ValueByRow(i)
c=len(a)
If c>0 Then
b=b+1
End If
Next
msgbox b

Is This Answer Correct ?    1 Yes 0 No

Question { Amazon, 4935 }

Hi, Anybody could tell me What is the 3rd Largest Number in
the series..Thanks in Advance..


Answer

a=array(1,22,3,40,12)
For i=0 to ubound(a)
For j=0 to ubound(a)
If a(i)>a(j) then
temp=a(i)
a(i)=a(j)
a(j)=temp
end if
Next
Next
print a(2)

Is This Answer Correct ?    1 Yes 0 No


Question { Syntel, 5935 }

QTP Data Table Having 10 records with 10 to 15 fields(lets
say).now i want to get alternative records from datatable.pls
can any one answer it?


Answer

datatable.AddSheet"pushkar"
datatable.ImportSheet "C:UserspushkarDesktopBook1.xls","Sheet1","pushkar"
rw=datatable.GetSheet("pushkar").GetRowCount
clm=datatable.GetSheet("pushkar").GetParameterCount
For i=1 to rw step 2
For j=1 to clm
a=datatable.GetSheet("pushkar").GetParameter(j).valuebyrow(i)
msgbox a
Next
Next

Is This Answer Correct ?    1 Yes 0 No

Question { Cap Gemini, 2354 }

We have a text file which contains 1 to 100 numeric values sequentially like 1
2
.
.
100
Now we have to count them and transfer to XML file by writing a code in qtp.


Answer

a="1 2 3 4 5 6 7 8 9 10"
b=split(a," ")
msgbox ubound(b)

Is This Answer Correct ?    0 Yes 0 No

Question { 5976 }

Find the 'String' from excel sheet and save to another
sheet.But we don't know the string column number and row number?


Answer

This is working code. Don't forget to save workbook else nothing will get saved. Code is:

Set obj=createobject("excel.application")
Set obj2=obj.Workbooks.Open("C:UserspushkarDesktopBook1.xls")
Set obj3=obj2.Worksheets("Sheet1")
Set obj4=obj2.Worksheets("Sheet2")
rw=obj3.usedrange.rows.count
clm=obj3.usedrange.columns.count
For i=1 to rw
For j=1 to clm
a=obj3.cells(i,j).value
If strcomp(a,"nature")=0 Then
obj4.cells(1,2)=a
End If
Next
Next
obj2.Save
obj.Quit

Is This Answer Correct ?    1 Yes 0 No

Question { 5997 }

write a function to read the items from Combobox of Flight
Reservation
application and save in excel.


Answer

a=browser("vtiger CRM - Commercial").Page("vtiger CRM - Commercial").WebList("login_theme").GetROProperty("all items")
b=split(a,";")
Set obj=createobject("excel.application")
Set obj2=obj.Workbooks.Open("C:UserspushkarDesktopBook1.xls")
Set obj3=obj2.Worksheets("Sheet1")
For i=0 to ubound(b)
j=i+1
obj3.cells(j,1)=b(i)
obj2.Save
Next

Is This Answer Correct ?    0 Yes 0 No

Question { 5997 }

write a function to read the items from Combobox of Flight
Reservation
application and save in excel.


Answer

It is very important too save workbook else sheet will be empty.

Is This Answer Correct ?    0 Yes 0 No

Question { 2727 }

How to capture the tooltip of webelement,if there are two
values displayed in tooltip of webelement?


Answer

B().P().Webelement().getroproperty("title")

Is This Answer Correct ?    0 Yes 0 No

Question { Cap Gemini, 6275 }

how to get the particular chr in an array list the question
is ....i have an array like this
ABCD
EBCF
GBCH
IBCJ
HERE I NET TO GET ONLY "BC" FROM ALL HOW TO GET IT
HELP ME ANY ONE

THANKS


Answer

This will print BC 4 times.

a="ABCD EBCF GBCH IBCJ"
b=Split(a," ")
For i=0 to ubound(b)
msgbox mid(b(i),2,2)
Next

Is This Answer Correct ?    0 Yes 0 No

Question { Broadridge, 6897 }

In Datatable having the data like this

S.no Name Address
1 raj hyderabad
2 suresh Mumbai
3 shyam chennai
4 dev banglore

i want to get the shyam row id & column id using scipting
i.e 3,3


Answer

a=datatable.GetSheet("Action1").GetRowCount
For i=1 to a
b=datatable.GetSheet("Action1").GetParameterCount
For j=1 to b
datatable.GetSheet("Action1").SetCurrentRow(i)
If datatable.Value(j,"Action1")="shyam" Then
msgbox i
msgbox j
End If
Next
Next

Is This Answer Correct ?    1 Yes 0 No

Question { 14879 }

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


Answer

a=inputbox("enter number")
b=len(a)
For i=b to 1 step -1
c=left(a,i)
d=d&c&vbnewline
Next
msgbox d

Is This Answer Correct ?    0 Yes 0 No

Question { IIT, 4097 }

What will be the output of the statements below?
On error Resume Next

Sum 100/0
if Sum= 0 Then
msgbox "Pass"

else
msgbox "Fail"

End If


Answer

It will result as "Pass". If we remove "On error resume next" line then "Divide by zero" error will be thrown by QTP.

Is This Answer Correct ?    0 Yes 0 No

Question { Thomson Reuters, 9200 }

Write script to fetch the data from global sheet where row
number is 3 and parameter is "text"


Answer

datatable.SetCurrentRow(3)
a=datatable.Value("A",dtglobalsheet)
msgbox a

Is This Answer Correct ?    1 Yes 0 No

Question { IBM, 2885 }

We have a dynamic webtable where rows keep on adding.I have to click on particular row where the status changes to Update or Save.How do you click on Status(either it can be Update or save)


Answer

rw=browser("Browser").Page("Page").WebTable("Table 1").RowCount
For i=1 to rw
a=browser("Browser").Page("Page").WebTable("Table 1").GetCellData(i,6)
If a="Hello" Then
Set b=browser("Browser").Page("Page").WebTable("Table 1").ChildItem(i,6,"webbutton",0)
b.click
End If
Next

Is This Answer Correct ?    1 Yes 0 No

Question { CTS, 2042 }

which is the easiest way you can send the QTP test results to Client if he want to see the screenshots when the results are failed?


Answer

We can add screenshots in your failed results through reporter.reportevent utility object.
Reporter.reportevent micdone, "results","http://file_path.bmp"

Is This Answer Correct ?    0 Yes 0 No

 [1]   2    Next