Micro Focus QTP (UFT) Forums
I can't displaying all the pages name in the .txt file - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: I can't displaying all the pages name in the .txt file (/Thread-I-can-t-displaying-all-the-pages-name-in-the-txt-file--2230)



I can't displaying all the pages name in the .txt file - njnirmal - 08-17-2009

I am using web application . I want to display my all the pages name . But i am not getting and some messge is displaying. error message is
"Type mismatch Line (21): "ln=total_no_link(i).getRoProperty("name")".
Why this error is displaying .
I am displaying my code .


Code:
Dim Total_no_link
Dim clink ,rc,mysmgbox
Dim ln
Set fileSysObject=createobject("Scripting.FileSystemObject")
Set linksFileName=fileSysObject.opentextfile("D:\a1.txt",2,true)
Set cLink =description.Create()
cLink("html").value="A"
Browser("Login Page").Page("Login Page").WebList("select").Select "SQL2005"
Browser("Login Page").Page("Login Page").WebList("select_2").Select "VIL0910SQL2005"
Browser("Login Page").Page("Login Page").WebEdit("txtUserID").Set "nj"
Browser("Login Page").Page("Login Page").WebEdit("WebEdit").SetSecure "4a89374a064976d6f9f1"
Browser("Login Page").Page("Login Page").WebList("select_3").Select "WHFD00"
Browser("Login Page").Page("Login Page").WebList("select_4").Select "WHFD00"
Browser("Login Page").Page("Login Page").WebList("select_5").Select "FOOD"
Browser("Login Page").Page("Login Page").WebButton("Enter").Click
Browser("Login Page").Page("Main Menu Page").Link("General Master").Click
Set rc=Browser("Login Page").Page("Main Menu Page").ChildObjects(cLink)
Total_no_link=rc.count()
For i=0 to total_no_link-1
[b]ln=total_no_link(i).getRoProperty("name")[/b]
linksFileName.writeline(link_name)
Next
linksFileName.close
Set fileSysObject=nothing


'mymsgbox=msgbox(total_no_link)
Browser("General Master").Page("General Master").WebButton("Exit").Click
Browser("Login Page").Page("Main Menu Page_2").Link("Exit").Click
Browser("Login Page").Page("Login Page_2").Sync
Browser("Login Page").Close


PLese tell me why this messge is displaying ..

Thanks in Advance


RE: I can't displaying all the pages name in the .txt file - basanth27 - 08-17-2009

Code:
Dim Total_no_link
Dim clink ,rc,mysmgbox
Dim ln
Set fileSysObject=createobject("Scripting.FileSystemObject")
Set linksFileName=fileSysObject.opentextfile("D:\a1.txt",2,true)
Set cLink =description.Create()
cLink("html").value="A"
Browser("Login Page").Page("Login Page").WebList("select").Select "SQL2005"
Browser("Login Page").Page("Login Page").WebList("select_2").Select "VIL0910SQL2005"
Browser("Login Page").Page("Login Page").WebEdit("txtUserID").Set "nj"
Browser("Login Page").Page("Login Page").WebEdit("WebEdit").SetSecure "4a89374a064976d6f9f1"
Browser("Login Page").Page("Login Page").WebList("select_3").Select "WHFD00"
Browser("Login Page").Page("Login Page").WebList("select_4").Select "WHFD00"
Browser("Login Page").Page("Login Page").WebList("select_5").Select "FOOD"
Browser("Login Page").Page("Login Page").WebButton("Enter").Click
Browser("Login Page").Page("Main Menu Page").Link("General Master").Click
Set rc=Browser("Login Page").Page("Main Menu Page").ChildObjects(cLink)
Total_no_link=rc.count()
msgbox Total_no_link ' What does msgbox display ?
For i=0 to Total_no_link-1
[b]ln=Total_no_link(i).getRoProperty("name")[/b]
linksFileName.writeline(link_name)
Next
linksFileName.close
Set fileSysObject=nothing
Try this code and let me know if you get the same error message.


RE: I can't displaying all the pages name in the .txt file - njnirmal - 08-17-2009

hi ..
Still same error message is displaying ? why its is displaying . ? Please tell me the reason behind this error so that next time i will not get the same problem


RE: I can't displaying all the pages name in the .txt file - Saket - 08-17-2009

Hi NJ,
The issue is there because you are taking the count of object at 'Total_no_link=rc.count()' which will return you an numeric value not an object. so when you do 'total_no_link(i)' in 'ln=total_no_link(i).getRoProperty("name")' it gives you the error. you should use the object (rc) here not the count.



'


RE: I can't displaying all the pages name in the .txt file - basanth27 - 08-17-2009

Absolutely Correct !! Saket's solution should definitely resolve the issue.

Thanks for looking in immediately saket. this will help njnirmal. I had him misled because i just saw that his variable has a spell mistake and pointed it out. The bigger picture was that he did not use rc.


RE: I can't displaying all the pages name in the .txt file - njnirmal - 08-17-2009

thanks for both of You .. for give me the reason for this error. please tell me one thing where i hve to change and what ?


RE: I can't displaying all the pages name in the .txt file - basanth27 - 08-17-2009

NjNirmal -
Please take sometime off to read through the entirety of the post. Saket and me spent sometime looking into your code and then we came up with the solution. Next time, please research on your own and if you cannot get the part post your question. We will be more than happy to help you. For now this is what saket meant,
Code:
Dim Total_no_link
Dim clink ,rc,mysmgbox
Dim ln
Set fileSysObject=createobject("Scripting.FileSystemObject")
Set linksFileName=fileSysObject.opentextfile("D:\a1.txt",2,true)
Set cLink =description.Create()
cLink("html").value="A"
Browser("Login Page").Page("Login Page").WebList("select").Select "SQL2005"
Browser("Login Page").Page("Login Page").WebList("select_2").Select "VIL0910SQL2005"
Browser("Login Page").Page("Login Page").WebEdit("txtUserID").Set "nj"
Browser("Login Page").Page("Login Page").WebEdit("WebEdit").SetSecure "4a89374a064976d6f9f1"
Browser("Login Page").Page("Login Page").WebList("select_3").Select "WHFD00"
Browser("Login Page").Page("Login Page").WebList("select_4").Select "WHFD00"
Browser("Login Page").Page("Login Page").WebList("select_5").Select "FOOD"
Browser("Login Page").Page("Login Page").WebButton("Enter").Click
Browser("Login Page").Page("Main Menu Page").Link("General Master").Click
Set rc=Browser("Login Page").Page("Main Menu Page").ChildObjects(cLink)
Total_no_link=rc.count()
For i=0 to Total_no_link-1
[b]ln=rc(i).getRoProperty("name")[/b]
linksFileName.writeline(link_name)
Next
linksFileName.close
Set fileSysObject=nothing



RE: I can't displaying all the pages name in the .txt file - njnirmal - 08-17-2009

thanks basanth ..
Next time i will try my self .. IF any issue comes then help me out

Once again thankx


RE: I can't displaying all the pages name in the .txt file - basanth27 - 08-17-2009

Good Spirit NjNirmal :-). Actually it should be Thanks to "Saket". He pointed the right mistake.


RE: I can't displaying all the pages name in the .txt file - manabh - 08-17-2009

Hi NjNirmal ,
It's a simple thing. Watch your code & see where you have received the collection of child objects. It's received in rc, & you are trying to iterate this collection through "Total_no_link" which is a variable assigned with only count of that collection. You have to retreive the values from the collection i.e. "rc" and not from "Total_no_link"