Anil
Anil

Reputation: 3992

How to link up to a browser in QTP?

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?

Upvotes: 1

Views: 4998

Answers (4)

Nayana
Nayana

Reputation: 11

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

Upvotes: 1

pavan
pavan

Reputation: 11

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.

Upvotes: 1

Dilip
Dilip

Reputation: 202

  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
    

Upvotes: 1

Xiaofu
Xiaofu

Reputation: 15889

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...

Upvotes: 2

Related Questions