Micro Focus QTP (UFT) Forums
Object does not exists - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Object does not exists (/Thread-Object-does-not-exists)



Object does not exists - shwetasharma - 02-28-2013

Hi All,

A very stange thing is happinig when i m tring to use dynamic code in my project

Here is my code

i want to check whether this link exists or not

Code:
browser("name:=.*").page("title:=.*").Link("html tag:=A","text:=+(91)-22-67732000","class:=ctc f13").exist

It says object does not exist
when i m using repository for this its working fine in following case
Code:
browser("xyz").page("xyz").Link("+(91)-22-67732000").exist

can anyone suggest whats wrong?

One more point the following code works fine in the same script

Code:
browser("name:=.*").page("title:=.*").WebElement("html tag:=A","class:=jdv","index:=0").Exist



RE: Object does not exists - pradeep singh - 02-28-2013

Escape the special characters by '\'. For ex: "+" change to "\+"
"(" change to "\(" and ")" change to "\)"
Now try again .


RE: Object does not exists - shwetasharma - 02-28-2013

Thanks pradeep

it worked ....

now i want to add that number in datatable so the code will be

Code:
browser("name:=.*").page("title:=.*").Link("html tag:=A","class:=ctc f13","text:="&DataTable("Number", dtGlobalSheet)).Exist


datatable will have
Number
\+\(91\)-22-67732000

is this the right way to do this?


RE: Object does not exists - pradeep singh - 02-28-2013

As per my understanding ...instead of direct putting no. in dp ,you are fetching from datatable....
If I am right then,make a function and pass parameter fetching value from datatable and in that function you append '\' to all special characters .


For ex:
Code:
p=DataTable("Number", dtGlobalSheet)
pchanged=fnReplacingSpecialChars(p)

Function fnReplacingSpecialChars(p)
p=Replace(p, "(", "\(",,,1)
p=Replace(p,"+","\+",,,1)
p=Replace(p, ")", "\)",,,1)
fnReplacingSpecialChars=p
End Function

Then write this as :
Code:
browser("name:=.*").page("title:=.*").Link("html tag:=A","class:=ctc f13","text:="& pchanged).Exist(0)



Let me know ,Is it worked for you or not?


RE: Object does not exists - shwetasharma - 03-01-2013

Thanks Pradeep .... it really helped me