Forum Discussion

royd's avatar
royd
Regular Contributor
6 years ago
Solved

JavaScript runtime error. TypeError: browser.Page is not a function

When I run the following, I get an error:

 

 function myTest(){
  Browsers.Item("iexplore").Run("https://www.mockaroo.com");

  var browser = Browsers.Item("iexplore");
  let page = browser.Page("*mockaroo.com*");   //error!

  ...
}

 

I never had this problem before! Help is much appreciated.

 

Thanks

 

Dave

  • Ah, I see it... 

    Your browser variable is storing the browser item from the Browsers object... it's not actually referencing the running web browser because... you haven't actually run it yet.

     

    EDIT:
    Misspoke.  So,  you are running the browser.  What you need to do then is assign your variable to the running system process.

    let browser = Sys.Browser('iexplore')

     

    Then you can call the page object all you want.

6 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    MY guess is that you have an object mapped as just straight "page" in your NameMapping.  Probably something like NameMapping.Sys.browser.page.  This is confusing TestComplete when you try and call the "Page" method of the actual browser object.

     

     

    • royd's avatar
      royd
      Regular Contributor

      Hi Robert

       

      Thanks for stopping by. I do not use NameMapping at all. But I checked it anyways to make sure there was nothing unexpected.

       

      My trouble started yesterday as I was working on a new test.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Ah, I see it... 

        Your browser variable is storing the browser item from the Browsers object... it's not actually referencing the running web browser because... you haven't actually run it yet.

         

        EDIT:
        Misspoke.  So,  you are running the browser.  What you need to do then is assign your variable to the running system process.

        let browser = Sys.Browser('iexplore')

         

        Then you can call the page object all you want.