Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is the problem with this code? Pls reply ASAP
#1
Not Solved
Hi All,

Can anyone answer this question please?

I am trying to capture the Privacy policy of Google and store in a Text file.

I have written the following code.

Code:
If browser("Google").Page("Google").Image("Google").Exist Then
    reporter.ReportEvent micDone, "google page", "google page is found"
    else
    reporter.ReportEvent micDone, "google page", "google page not found. Exiting"
    ExitAction()
End If
If browser("Google").Page("Google").Link("Privacy").Exist Then
    reporter.ReportEvent micDone, "Google privacy", "google privacy link found"
    else
    reporter.ReportEvent micDone, "google privacy", "google privacy link not found.Exiting"
    ExitAction()
End If
If browser("Google").Page("Google").Link("Privacy").Exist Then
    browser("Google").Page("Google").Link("Privacy").Click()
End If
If browser("Google").Page("Privacy Center").Link("Privacy Policy").Exist Then
    reporter.ReportEvent micDone, "Privacy center", "Privacy center page found"
    else
    reporter.ReportEvent micDone, "Privacy center", "privacy center page not found. Exiting"
    ExitAction()
End If
If browser("Google").Page("Privacy Center").Link("Privacy Policy").Exist Then
    browser("Google").Page("Privacy Center").Link("Privacy Policy").Click()
End If

If browser("Google").Page("Privacy Policy – Google").WebButton("Search").Exist Then
    reporter.ReportEvent micDone,"Privacy policy", "you are in the right page"
    else
    reporter.ReportEvent micDone,"Privacy policy", "You are in the wrong page"
End If
Dim str
If browser("Google").Page("Privacy Policy – Google").WebButton("Search").Exist Then
    str=browser("Google").Page("Privacy Policy – Google").GetROProperty("innertext")
  
End If
Dim fso, File1, File2
Set objFSO=CreateObject("Scripting.FileSystemObject")
objFile1=FSO.CreateTextFile("C:\testfile.txt", true)

Const ForWriting=2
Set objFSO=CreateObject("Scripting.FileSystemObject")
objFile2=FSO.OpenTextFile("C:\testfile.txt", ForWriting, True)

objFile1.write str

All the lines are executed successfully till it reaches CreateTextFile line.

Please let me know what did I miss in the above code?

Earliest reply is highly appreciated!
Thanks,
Kishore
Reply
#2
Not Solved
Dear Kishore Every thing is fine what you need to do is
Objects which u created names are mismatching so correct all names then u can run smoothly.
Code:
Dim fso, objFile1, objFile2
Set objFSO=CreateObject("Scripting.FileSystemObject")
objFile1=objFSO.CreateTextFile("C:\testfile.txt", true)

Const ForWriting=2
Set objFSO=CreateObject("Scripting.FileSystemObject")
objFile2=objFSO.OpenTextFile("C:\testfile.txt", ForWriting, True)
objFile1.write str

here is the code
let me kwow ur resukts
Reply
#3
Not Solved
Dear Seetu,

Thanks for your response. However, I am getting 2 errors. #1.Permission denied #2.Object required. Please provide any possible solution to solve this.

Looking forward to hear from you,
Kishore
Reply
#4
Not Solved
Dear Kishore
Here is the code for the same
Code:
Dim obfso, objFile1,objFile2
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFile1=objFSO.CreateTextFile("C:\testfile.txt", true)
objfile1.close

Const ForWriting=2
Set objFSO=CreateObject("Scripting.FileSystemObject")
set objFile2=objFSO.OpenTextFile("C:\testfile.txt", ForWriting, True)

objFile2.write str


I think it works
let me know if u need further assistance.
Reply
#5
Not Solved
Dear seetu,

Thanks for your reply. But, unfortunately I am getting the same error mesgs, unable to move further.
Please suggest some other solution
Reply
#6
Not Solved
Dear Kishore pls use the following code.
it is working fine in my Environement.

Code:
Dim objFSO,objFile1,objFile2
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFile1=objFSO.CreateTextFile("C:\testfile.txt", true)
objfile1.close

Const ForWriting=2
Set objFSO=CreateObject("Scripting.FileSystemObject")
set objFile2=objFSO.OpenTextFile("C:\testfile.txt", ForWriting, True)

objFile2.write str
objFile2.close
Reply
#7
Not Solved
I am getting "Permission denied" error message. However, I tried in my Office, I was able to create a Text file. Later, by right clicking its properties, I have changed the permission, then I was able to get all the text which I captured from the web page. But on my laptop, I am unable to create a file. I have changed the permission settings for the folder, Temp also. Any suggestions?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to solve / record SAP (Transaction code PA40) Infotypes sequence problem in QTP kamal262007 0 2,298 02-04-2013, 11:25 AM
Last Post: kamal262007
  systemUtil.run script is not generating while recording in qtp 9.5..pls help me senthil.kumar 0 2,681 01-24-2013, 01:22 PM
Last Post: senthil.kumar
  QTP gets crashed on start up or on save a script. Pls advise pandeche 2 3,498 04-16-2012, 12:14 PM
Last Post: leema
  Please suggest some books to learn VBScript basics for qtp. Pls share if u have any. GSuba 0 4,072 04-08-2011, 12:55 AM
Last Post: GSuba
  Does any has .ISO file/package for QTP 9.0 or QTP 10 or QTP 11 ..Email pls? amipraj1 1 3,551 04-06-2011, 09:52 AM
Last Post: manishbhalshankar

Forum Jump:


Users browsing this thread: 1 Guest(s)