dp part 4 general issues
TRANSCRIPT
8/8/2019 DP Part 4 General Issues
http://slidepdf.com/reader/full/dp-part-4-general-issues 1/13
8/8/2019 DP Part 4 General Issues
http://slidepdf.com/reader/full/dp-part-4-general-issues 2/13
8/8/2019 DP Part 4 General Issues
http://slidepdf.com/reader/full/dp-part-4-general-issues 3/13
8/8/2019 DP Part 4 General Issues
http://slidepdf.com/reader/full/dp-part-4-general-issues 4/13
So what went wrong? The problem was with the characters "(" and ")" present in the text of the link
we used. By default QTP treats all DP properties as regular expression (r.e.) patterns and "(xxx)"
is considered as a group of patter xxx. The text "Logout (Tarun)" when treated as a r.e. gets a
literal meaning of "Logout Tarun", and since there is no such link on the web page QTP throws an
error. To avoid such situations we need to escape the regular expression characters using the
escape character "\". Now we have three different solutions to correct the problem
Method 1
Browser("miccclass:=Browser").Page("micclass:=Page"). _
Link("text:=Logout \(Tarun\)").Click
Method 2
8/8/2019 DP Part 4 General Issues
http://slidepdf.com/reader/full/dp-part-4-general-issues 5/13
For QTP Realtime Scripts, visit
www.ramupalanki.com
Set oDesc = Description.CreateoDesc("text").Value = "Logout \(Tarun\)"
Browser("miccclass:=Browser").Page("micclass:=Page").Link(oDesc).Click
Method 3
8/8/2019 DP Part 4 General Issues
http://slidepdf.com/reader/full/dp-part-4-general-issues 6/13
Set oDesc = Description.Create
oDesc("text").Value = "Logout (Tarun)"
'Do not treat the value as regular expression.
oDesc("text").RegularExpression = False
Browser("miccclass:=Browser").Page("micclass:=Page").Link(oDesc).
Click
IMO Method 3 should be preferred for a neater coding as we are using the actual text of the link.
Overpopulated description while identifying objects
An overpopulated description does not help in recognizing the object. We should useminimum no. of properties which are stable enough to recognize the object on every
single run. Consider the below overpopulated description
Set oDesc = Description.CreateoDesc("html tag").Value = "TABLE"oDesc("micclass").Value = "WebTable"oDesc("innertext").Value = "abcde"oDesc("outertext").Value = "abcde"
oDesc("innerhtml").Value = "<TR><TD>abcde</TD></TR>"
oDesc("outerhtml").Value =
"<TABLE><TR><TD>abcde</TD></TR><TABLE>"
oDesc("rows").Value = 1
oDesc("cols").Value = 1
8/8/2019 DP Part 4 General Issues
http://slidepdf.com/reader/full/dp-part-4-general-issues 7/13
For QTP Realtime Scripts, visit
www.ramupalanki.com
Consider the following advices while create such a description
· rows and cols are dynamic properties which might change if the table gets
updated. These properties should be avoided
· Only one of the properties from innertext, outertext, outerhtml and innerhtml
should be used
· outerhtml and innerhtml properties should be avoided as they contains various
tags and difficult to express
· When using Browser().Page().WebTable(oDesc) we can skip specifying the
micclass and html tag properties also because as soon as we enclose oDesc
with the WebTable() test object these two properties are mostly implied.
8/8/2019 DP Part 4 General Issues
http://slidepdf.com/reader/full/dp-part-4-general-issues 8/13
Considering the above points we can reduce our description to just
Set oDesc = Description.Create
oDesc("outertext").Value = "abcde"
Underpopulated description while using ChildObjects
Though we reduced the no. of properties in the description object when identified a table in
the last section but while using ChildObjects method we should make sure the following
· Maximum description properties should be used to reduce the final result set. Though
we should still follow the advices specified in earlier section of overpopulated
descriptions except the last one (Where we ignore micclass and HTML tag).
· When using ChildObjects to find WebElements, "html tag" should always be
provided to avoid errors.
·Property names used in description should be as the same case provided in the QTPhelp file. IMO changing the case sometimes causes general run error during script run.
Though there is no documentation proving that description names are case sensitive
Using "Class Name" instead of "micclass"
Don’t know why by Mercury/HP preferred to show micclass as "Class Name" in the object spy.
This misleads many DP user to create a description with non-existent property class name
8/8/2019 DP Part 4 General Issues
http://slidepdf.com/reader/full/dp-part-4-general-issues 9/13
For QTP Realtime Scripts,
visit www.ramupalanki.com
8/8/2019 DP Part 4 General Issues
http://slidepdf.com/reader/full/dp-part-4-general-issues 10/13
8/8/2019 DP Part 4 General Issues
http://slidepdf.com/reader/full/dp-part-4-general-issues 11/13
For QTP Realtime Scripts,
visit www.ramupalanki.com
'Below is the wrong way
Browser("Class Name:=Browser")
'Below is the right way
Browser("micclass:=Browser")
8/8/2019 DP Part 4 General Issues
http://slidepdf.com/reader/full/dp-part-4-general-issues 12/13
'Below is the wrong way
Set oDesc = Description.Create
oDesc("Class Name").Value = "Browser"
oDesc("title").Value = "My title"
8/8/2019 DP Part 4 General Issues
http://slidepdf.com/reader/full/dp-part-4-general-issues 13/13
For QTP Realtime Scripts,
visit
www.ramupalanki.com
'Below is the right way
Set oDesc = Description.Create
oDesc("micclass").Value = "Browser"
oDesc("title").Value = "My title"
These are few general issues that people face.