cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Highlighted
Regular Contributor

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!

  ...
}

typeerror.png

 

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

 

Thanks

 

Dave

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

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

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.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

6 REPLIES 6
Highlighted
Community Hero

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

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.

 

 


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Regular Contributor

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

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.

Highlighted
Community Hero

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

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.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

Highlighted
Regular Contributor

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

Okay, I tried 

let browser = Sys.Browser("iexplore");

and it worked.

 

I am still wondering why Browsers.Item failing. I have used that numerous time!

Highlighted
Community Hero

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

I'm not sure why it worked for you before.  Basically, what that line is doing is returning a BrowserInfo object, not the actual Browser process running in Windows.  So, the fact that it used to work is what is the mystery to me.

Oh, well... it works now.  🙂


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Regular Contributor

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

Yes I am glad it is working. Thank you. 🙂

New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
A new challenge is here!

Create a function to drag one element to another for the TechCorner tag!

Will you dare to take the challenge?


Scripts created in July:
- Passing custom command-line arguments as a test parameter
Top Kudoed Authors