The online community for software testing & quality assurance professionals
 
 
Calendar   Today's Topics
Sponsors:
Lost Password?

Home
BetaSoft
Blogs
Jobs
Training
News
Links
Downloads



Testing Tools >> HP Functional Testing / Mercury QuickTest Pro / QTP

Pages: 1
yz0n0
Member


Reged: 07/21/03
Posts: 16
QTP cannot identify an object
      #219267 - 02/01/06 09:25 PM

Hi,

I’m facing the problem that QTP cannot identify an object while playing back. Run Error pops up: “Cannot found this object….” The reason is the property (coordinate: x or y) of obj is being changed sometime. Create a description object with the following code:

Problem 1:
Set table_desc=Description.Create()
table_desc(“Class Name”).value=”WebTable”
table_desc(“html tag”).value=”Table”
table_desc(“x”).value=”157”
table_desc(“y”).value=”253” ‘the value of y keeps changing, like 254, 306, etc
link_no=Search_Page.WebTable(table_desc).ChildItemCount(1,1,”Link)
msgbox “link no” &link_no

problem 2:
Set drug_txt=Description.Create()
drug_txt(“Class Name”).value=”H2”
drug_txt(“x”).value=”157” ‘the value of x changes only once after running 118 drugs, like, 142
drug_txt(“y”).value=”294” ‘the value of y keeps changing, like 301, 306 etc
drug_name=Patienthandout_Page.WebElement(drug_txt).GetRoProperty(“innertext”)
msgbox drug_name

Can I consider x or y as regular expression in order to match values that vary at runtime ?

Solution for issue 1: table_desc(“y”).value=”\d*” or table_desc(“y”).value=”[2-3][0-9]+”

Solution for issue 2:
drug_txt(“x”).value=”1[0-9]+”
drug_txt(“y”).value=”[2-3][0-9]+”

Please coorect me if I'm wrong. Any note, suggestion and help will be appreciated.

Yu


Post Extras: Print Post   Remind Me!   Notify Moderator  
Tarun LalwaniModerator
Veteran


Reged: 07/21/05
Posts: 15329
Loc: Milwaukee, Wisconsin
Re: QTP cannot identify an object
      #219268 - 02/02/06 12:13 AM

Why have you choosed x and y properties to identify an object. These properties are too dynamic and should never be used. Look for some other properties i would say.

Post Extras: Print Post   Remind Me!   Notify Moderator  
yz0n0
Member


Reged: 07/21/03
Posts: 16
Re: QTP cannot identify an object
      #219269 - 02/02/06 11:29 AM

Hi,

As per your suggestion, the issue 1 has been solved and worked. but not for issue 2. Here is the code I’m referring to your DP document

Set drug_txt=Description.Create()
drug_txt("Class Name").value="WebElement"

drug_txt("html tag").value="H[0-9]” ‘Using spy to get value of html tag, and always display ‘H1’ or H3’. So I’d considerate of these value can be replaced with reg expression.

'drug_txt ("x").value="157"
'drug_txt ("y").value="301"

drug_name=Patienthandout_Page.WebElement(drug_txt).GetRoProperty(“innertext”)

After that, the Run Error pops up: “General Error.” It means that QTP did not go through and create description of desired object.


Would u please provide a pieace of code according the statement described above?

Thanks
Yu

[ 02-02-2006, 11:45 AM: Message edited by: yz0n0 ]


Post Extras: Print Post   Remind Me!   Notify Moderator  
Wasim Haque
Member


Reged: 10/17/05
Posts: 398
Loc: Universe
Re: QTP cannot identify an object
      #219270 - 02/02/06 11:47 AM

Hi,

Try using.....

drug_txt("html tag").value="H.*"

If this fails, try adding some more properties to create description.

And one advice never use x and y coordinates to create description of an object as Tarun mentioned above.

Thanks,
Wasim


Post Extras: Print Post   Remind Me!   Notify Moderator  
Tarun LalwaniModerator
Veteran


Reged: 07/21/05
Posts: 15329
Loc: Milwaukee, Wisconsin
Re: QTP cannot identify an object
      #219271 - 02/02/06 01:08 PM

drug_txt("Class Name").value="WebElement"

this should be micClass actually

drug_txt("micClass").value="WebElement"

and when you say Browser().Page().WebElement(drug_txt) then you already say that micClass is webelement, so you dont need to describe that in the description object.


Post Extras: Print Post   Remind Me!   Notify Moderator  
yz0n0
Member


Reged: 07/21/03
Posts: 16
Re: QTP cannot identify an object
      #219272 - 02/02/06 02:12 PM

Tarun,

I used “class name” to define other class of obj in the same script. All went through fine. So, either one is ok for me.

Wasim,

The way u provided was being tried already. Unfortunately, the script failed again. “General run error”. Just wondering has this solution ever been successful before?

Should we try another way to solve this issue? Let me give u brief describe about this page and how did they present.

For example: search drug ‘Advil’ > the system received drug patient handout page > It contains brand name: ‘Advil oral’(html tag:H1) and generic name: ‘IBUPROFEN CHEWABLE - ORAL’(html tag:H3) on the same page > the test objective is to capture the text of drug > test done!

Search anther drug ‘bio-immunex oral>the system received drug patient handout page > It contains brand name: ‘bio-immunex oral (html tag:H3) only. No generic name is available, instead of text: NO MONOGRAPH AVAILABLE AT THIS TIME (html tag:H3)

The below is captured the properties for advil oral as sample. All drugs mentioned above have common properties only slight different, like html tag, innertext, etc. Please look at properties of obj:

Class Name WebElement
abs_x 664
abs_y 430
class
height 21
html id
html tag H1
innerhtml Advil Oral
innertext Advil Oral
outerhtml <H1 style="FONT-SIZE: 18px; MARGIN: 0px">Advil Oral</H1>
outertext Advil Oral
type
visible 1
width 430
x 157
y 294

So what’s the best solution can be used for the issue described above.

Thanks
Yu


Post Extras: Print Post   Remind Me!   Notify Moderator  
Tarun LalwaniModerator
Veteran


Reged: 07/21/05
Posts: 15329
Loc: Milwaukee, Wisconsin
Re: QTP cannot identify an object
      #219273 - 02/02/06 02:23 PM

Can you send source code of your web page for all possible scenario that might occur. With the source code it would be easier to comment on the issue. my email id is tarun_lalwani_2000(at)yahoo(dot)com

Post Extras: Print Post   Remind Me!   Notify Moderator  
yz0n0
Member


Reged: 07/21/03
Posts: 16
Re: QTP cannot identify an object
      #219274 - 02/02/06 02:53 PM

Here we go! Below is the Patinet Handout page:

http://aolsvc.health.webmd.aol.com/drugs/drug-6040-Zocor+Oral.aspx?drugid=6040&drugname=Zocor+Oral

search term: 'zocor oral' or 'fiber clear oral'
Patient Handout page - brand name:Zocor Oral(H1) and generic name:SIMVASTATIN - ORAL (H3)
Patient Handout page - brand name:Fiber Clear Oral(H3)and NO MONOGRAPH AVAILABLE AT THIS TIME(H3)

Test objective: capture the name of drug at top only, like: Zocor Oral, Fiber Clear Oral, etc


Post Extras: Print Post   Remind Me!   Notify Moderator  
Tarun LalwaniModerator
Veteran


Reged: 07/21/05
Posts: 15329
Loc: Milwaukee, Wisconsin
Re: QTP cannot identify an object
      #219275 - 02/02/06 06:23 PM

Well it's displayed in a column of a web table. So when you add the webelement to OR then add the parent webtable for it. Then use GetCellData function to devise a method to get the exact name displayed.

Post Extras: Print Post   Remind Me!   Notify Moderator  
yz0n0
Member


Reged: 07/21/03
Posts: 16
Re: QTP cannot identify an object
      #219276 - 02/04/06 12:49 AM

Tarun,

Please look at the following codes according your advise,

Browser("WebMD Health - Patient").Page("WebMD Health - Patient").WebEdit("query").Set ("fiber clear oral")
Browser("WebMD Health - Patient").Page("WebMD Health - Patient").Image("GO").Click
Browser("WebMD Health - Patient").Page("WebMD Health - Drug Search").Link("Fiber Clear Oral").Click
Browser("WebMD Health - Patient").Page("WebMD Health - Patient").Sync
Set table_desc=Description.Create()
table_desc("Class Name").value="WebTable"
table_desc("html tag").value="Table"
table_desc("name").value="430DottedLine"

Set TAB = Browser("WebMD Health - Patient").Page("WebMD Health - Patient").WebTable(table_desc)
cell_data=TAB.GetCellData(1,1)
msgbox cell_data
txt_len=len(cell_data)
msgbox txt_len
If txt_len<>0 Then
index =InStr(cell_data, ":")
If index <>0 Then
STRArray = Split(cell_data, ":", -1, 1)
cell_str=STRArray(0)&":"
msgbox cell_str
data_to_cell="Drug Name : "&cell_str
msgbox data_to_cell
end if
end if

The problem is how to capture desired value of drug like: ‘fiber clear oral’ ,etc. Because of each String expression (string2) searched for is not consistent. In the code, I have no clue what string2 can be. The below samples are for all possible scenario that might occur. For example:

String1: fiber clear oral (drug name)
String 2: Important Note: The following information….

String 1: zocor (drug name)
String 2: brand names | uses | side effects | precautions | interactions | overdose Important Note: The following information….

String 1: AllanHist PDX Infant Oral (drug name)
String2: uses | side effects | precautions | interactions | overdose Important Note: The following information….

String 1: Certa Plus SENIOR Oral (drug name)
String 2: warning | uses | side effects | precautions | interactions | overdose Important Note: The following information….


Please use below the url,
http://aolsvc.health.webmd.aol.com/drugs/drug-92916-Fiber+Clear+Oral.aspx?drugid=92916&drugname=Fiber+Clear+Oral

Manually run all drugs provided above to get basic idea about how drug name showed up, pl also notice near around string expression. You may have the best solution to parse the captured text. Can u attach sample code for this particular issue?

Thanks a lot
Yu


Post Extras: Print Post   Remind Me!   Notify Moderator  
yz0n0
Member


Reged: 07/21/03
Posts: 16
Re: QTP cannot identify an object
      #219277 - 02/06/06 02:32 PM

Hi Expert,

The problem we discussed above has been solved finally. The solution is to create web table description and get data from cell. Also using string function ‘Instr’ and verify whether it returns the position of the first occurrence of one string within another string. if yes, QTP writes value of drug name into data table otherwise the message "string is mismatch" will be indicated.

Thanks for all your suggestion.
Yu

[ 02-06-2006, 02:38 PM: Message edited by: yz0n0 ]


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
1 registered and 71 anonymous users are browsing this forum.

Moderator:  IanFraser, Rajkumar_Rajangam, thorwath, TReddy, AJ, Tarun Lalwani, mwsrosso 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 2052

Rate this topic

Jump to

Contact Us | Privacy statement SQAForums

Powered by UBB.threads™ 6.5.5