Forum Discussion

suzanne_raine's avatar
suzanne_raine
Contributor
10 years ago

How to make the browser navigate to my URL?

Hi, 

I'm trying to make my browser navigate to a URL.

 

I've tried the following code:

 

Sys.Browser("iexplore").ToUrl("www.google.com");

and also 

Sys.Browser("iexplore").Navigate("www.google.com");

 

but my test fails:

Unable to find the object Sys.Browser("iexplore"). 

The object does not exist. 

 

 

Can anyone help?

16 Replies

  • Lage's avatar
    Lage
    Contributor

    you can use .ToUrl or .Navigate when yout browser is already running. 

     

    for this reason you should check first if your browser is running, 

     

    Sub invokeURL
      If Sys.WaitProcess("iexplore",2000).Exists then
        Browsers.Item("iexplore").Navigate("www.google.com")
      Else
       Browsers.Item("iexplore").Run("www.google.es")
      End If
    End Sub

     

    Anyway, I recomend you to put your baseURL and browser in a Project.Variables and use them if you wants to change the browser or the environment.

     

    Project.Variables.Browser

    Project.Variables.baseURL

     

    kind regards

    • suzanne_raine's avatar
      suzanne_raine
      Contributor

      Hi,

       

      Thanks for your response! I've tried that code, but it's the same errors again. 

       

      It also should recognise that my browser is running because it's just a follow on from some code that I know already works. 

       

      • Lage's avatar
        Lage
        Contributor

        Could you please check the properties of your Browser stored in the NameMapping?

        Try also to highlight the browser on Screen.

        Maybe you have there some properties that don't help with the browser recognition. 

         

        2015_05_13_TestComplete_BrowserIdentification.png

         

        Hope it helps. waiting.

        regards,

        Lage

         

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Suzanne_raine,

     

    Is the IE browser launched before you start executing your code?

    If it’s not launched, you can use the following code:

    Browsers.Item(btIExplorer).Run("http://smartbear.com");
    • suzanne_raine's avatar
      suzanne_raine
      Contributor

      Hi,

       

      Yes I also tried that. It opens the browser - i.e. it runs that bit of code fine, but then won't get past the second line. 

      • Lage's avatar
        Lage
        Contributor

        Can you highlight the page that you want to open?  

         

        note: About one of my previous post...it is usuall that the Browser can not be highlighted. No worry about that. Just try to highlight the inmediate object below (should be a page).

         

        Can you modify your Maped Objects properties like this ones below? then, open www.google.com and try to highlight.  Important! Note the '*' stars in the URL.  (better with iexplore)

         

        tell us something

         

        2015_05_15_hightlight_google.png