Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QTP Tips and Tricks
#11
Hi Rajpes,

you said in above comment that it would be not good to use for best practice the Systemutil.Run

SystemUtil.Run "www.google.com"

can u provide/ tell me then which is the best practice
(07-26-2011, 03:24 PM)rajpes Wrote: SystemUtil.Run "www.google.com"
'yes,it works!not a good practice though


Hi Rajpes,

you said in above comment that it would be not good to use for best practice the Systemutil.Run

SystemUtil.Run "www.google.com"

can u provide/ tell me then which is the best practice
Reply
#12
I did not mean that SystemUtil.Run is not good practice, i don't think any other alternative for this.
i meant directly writing web url (by omitting 'iexplore' )may not be good practice
Reply
#13
no need to initialize a counter to zero before entering into a do loop

do until some condition is true
c=c+1 'you don't have to specify c=0 before this do loop, numerics are assigned 0 by default if not initialized
loop
Reply
#14
while working with excel sheets, save time by writing "sheets" in place of "worksheets" , both do same task
Reply
#15
If there is need to get all items of combobox to an array,QTP provides a method "GetContent" through which all items are returned as a single string.
Now to separate them into an array, use split with delimiter as vblf
Code:
AllItems=Window("Flight Reservation").WinComboBox("Fly From:").GetContent
arr=split(AllItems,vblf)
msgbox ubound(arr)
Reply
#16
when you want to load an externally created sheet using
1)Import:You have to make use of GetCurrentRow & SetCurrentRow methods to loop over the rows because in every iteration the whole sheet is imported freshly which resets CurrentRow to 1 everytime!
where as using
2)Importsheet: the CurrentRow is unaffected by multiple imports. so you don't have to use SetCurrentRow method here
Reply
#17
Code:
r=Browser("xyz").Page("xyz").webtable("xyz").RowCount

ReDim a(r-2) 'first row is column names

For i=2 to r
'sort 3rd column
a(i-2)=Browser("xyz").Page("xyz").webtable("xyz").GetCellData(i,3)
Next

sort=true
For i=0 to ubound(a)-1
    If a(i)>a(i+1) Then
        sort=false
    End If
Next
msgbox  sort
Reply
#18
1. Write "regedit" under run, then go to HKEy_LOCAL_MACHINE ->Software->Mercury Interactive->Quicktest professional-> logger->Media->Log
2. Then change the value for "Active" under "Log" from 0 to 1.
3. Now execute your automation script and go to the corresponding Result folder for that script. You can see a folder named as "Log" present there.
4. Go to that "Log" folder, now you can find a html file named as "LogFile.html". Open that file, it will display whole test results and their summary. At the bottom of that LogFile html page, you can find a webelement named as "ExecutionTongueassed" or "Execution Failed" depends on the status.
Reply
#19
Shy 
If a password is already entered in a textbox by someone which appears in the form of dots or stars,3 ways of hacking that password

1)using object spy, you can check the "value" property
2)equivalently, msgbox TextBoxObject.getroproperty("value")
3)click record , go to that password textbox, give 2 spaces in the end and 2 back spaces(to remove your characters).Now a setsecure statement would be generated in your script
eg:TextBoxObject.setsecure "4e93d473e107b51e592f945561gb0263bsa70f17013dcde96ef7"

Now, if you have another textbox on the page(eg:username)
write this line in next line of the script
WebEdit("username").setsecure "4f276558710344aa1ef240e0e53a"

Now run it and see that the password appears on the username textbox Tongue
Reply
#20
(07-25-2011, 11:49 AM)rajpes Wrote: Let us share some tips and tricks we come across when working with QTP.

If you want to share a New trick,add appropriate title in the "Post Subject" after clicking on the "New Reply" link.





Setting.Add trick to use run session values in next run sessions


Suppose you want to save some values manipulated in the run session somewhere so that you would like use them for next run session, the only ways(i think) are to save them to some external files like excel or output the values to global sheet.

I just went through the topic
"Setting Testing Options During the Run Session" which explains about
Setting.Add through which we can add some key value pairs more or less same like Environment variables

If you change the user defined Environment variables(pre-defined or dynamically created) in run time,they are all lost when the run session ends as they are reset to their original values and it can throw error if you try to use some dynamically created Environment variables of the last run !


So,the trick which i found is,
Just save your values in the form of 'key value pair' to Setting.Add "key","value"
which once created can be accessed in any run session thereafter.

Example of how to use it.
Code:
If Not Setting.Exists("IterNum") then
Setting.Add "IterNum", 1 'create "IterNum" and assign to 1
else
msgbox Setting.Item("IterNum") 'Use it or modify it as written below
Setting.Item("IterNum")=Setting.Item("IterNum")+1 ' modify "IterNum"
end if
Now run this and see, first time you run, it will create a new setting item and next time you run, the message box promt will show the value.

Isn't it cool?Shy

Note:These values will not be saved with the test after you close the test or open some other test(or create a new test)l!

Hi,
Nice iniciative.
The method you posted is something like Global Dictionary, where we can add values on the basis of keys.

Please clariffy my doubt.

Regards,
Sankalp
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)