Question

I am new to qtp and this is a sample script in which I am facing a few errors like "URL might be wrong".

Browser ("Google").Navigate ( "http://www.google.com")
Browser ("Google"). Page ("Google").Sync
Browser ("Google"). Page("Google").  WebEdit("q:"). Set (" tarun lalwani")
Browser ("Google") .Page  ("Google"). WebButton ("Google Search").Click
Browser ("Google") .Page (" tarun lalwani - Google").link ("knowledgeInbox").Click
Browser ("Google").Page ("knowledgeInbox").Sync
Browser ("Google") .close 

What is going wrong?

Was it helpful?

Solution

I can see you've taken the example from Tarun's website. A couple of questions/pointers:

  1. Is this all the code from your sample script?

  2. Do you have the object repository that I expect comes with this example script?

  3. Are all those random spaces present in your actual QTP code?

  4. What exact error message are you getting? I think "URL might be wrong" is probably not what you're really getting...

OTHER TIPS

  1. Check whether you stored objects in the object repository

  2. Try the below mentioned code

    Set IE = CreateObject("InternetExplorer.Application")
    IE.Navigate "http://www.google.co.in"
    IE.Visible = True
    IE.Document.All.Item("q").Value = "serach"
    IE.Document.All.Item("f").submit()
    
  3. There shoudl be no spaces in the code. For example your script is

    Browser ("Google") .Page  ("Google"). WebButton ("Google Search").Click
    

    it should be

    Browser("Google").Page("Google").WebButton("Google Search").Click
    

You should specify the browser:

browser("IE").Page("website name").etc.......

Or store it in a variable:

set a=browser("IE").page("name of ur site etc")
a.webedit("name of text field").set "pavan"
a.webbutton("search").click

You can also create a local repository before running the script.

SystemUtil.Run "iexplore","URL of the application"
With Browser("A").Page("B")
    .WebEdit("Logical Name of the Text Field").Set"SearchKeyText"
    .WebButton("Text label of the Button").Click
End With
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top