Ask a Question

navigation browser / page

SOLVED
lambada
Contributor

navigation browser / page

Hi everybody.

 

I would like to declare the page (browser) because I need it later to access on it on other objects. The necessary page is already open.

 

I used:

 

function DB() {

 

var url = "http://.............../";

Browsers.Item(btChrome).Run(url);

 

var page = Sys.Browser("*").Page(url);


Sys.Browser().BrowserWindow(0).Maximize();

 

...

}

 

When I use it, the page will a kind of "refresh" with this code. 

What can you alternatively recommend me how to do it?

 

Thank you very much in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
tristaanogre
Community Hero

Re: navigation browser / page

Even easier than that.

 

 

function getMyPage(url){
   return Sys.Browser('chrome').Page(url);
}

 

That is, assuming that the desired page exists.

 

In truth, though, I would map the object.  So, there would be, in my NameMapping, something like

 

Aliases.browser.pageMyPage

 

the pageMyPage object would have as the identifying properties the ObjectType of Page and then url being the the url.  Then, everytime I want to reference that page in my code, all I need to do is reference the Alias.

 

And, one step further, if I want to make sure, when I'm referencing the page, that it actually exists and do validation on it (like if I click a button and expect a particular page), I can do something like

 

Aliases.browser.myFirstPage.myNavigateButton.ClickButton();
if (!Aliases.browser.WaitAliasChild('mySecondPage', -1).Exists){
    throw Error('The desired page did not come up after clicking on my button');
}

 


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

7 REPLIES 7
tristaanogre
Community Hero

Re: navigation browser / page

You're calling the "run" method on your browser object... by definition, that will attempt to run a copy of your browser to the URL in question.

 

Instead of "Run", all you really need to do is assign your variable... there's no need to run the browser simply to get the page.

 

Additionally...  if you're using NameMapping, there's no need for the code you've written.  A page can be mapped and then, everytime you need to access the page, you simply reference the Alias for it.


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
lambada
Contributor

Re: navigation browser / page

Thank you very much!

 

So you mean, instead of "run" i have to take "page"? Like Browsers.Item(btChrome).page; ?

tristaanogre
Community Hero

Re: navigation browser / page

Even easier than that.

 

 

function getMyPage(url){
   return Sys.Browser('chrome').Page(url);
}

 

That is, assuming that the desired page exists.

 

In truth, though, I would map the object.  So, there would be, in my NameMapping, something like

 

Aliases.browser.pageMyPage

 

the pageMyPage object would have as the identifying properties the ObjectType of Page and then url being the the url.  Then, everytime I want to reference that page in my code, all I need to do is reference the Alias.

 

And, one step further, if I want to make sure, when I'm referencing the page, that it actually exists and do validation on it (like if I click a button and expect a particular page), I can do something like

 

Aliases.browser.myFirstPage.myNavigateButton.ClickButton();
if (!Aliases.browser.WaitAliasChild('mySecondPage', -1).Exists){
    throw Error('The desired page did not come up after clicking on my button');
}

 


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

lambada
Contributor

Re: navigation browser / page

Thank you, that´s very kind of you 🙂

tristaanogre
Community Hero

Re: navigation browser / page

If you have not done so already, I would highly recommend you sign up for and attend a TestComplete 101 webinar to get a more comprehensive introduction to the tool and how to make use of the different features.


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
lambada
Contributor

Re: navigation browser / page

I will have a look to it! Thank you very much!

tristaanogre
Community Hero

Re: navigation browser / page

There is a class scheduled for tomorrow at 11 AM Eastern US time and another scheduled for May 17th at 8 AM AEST.

 

https://smartbear.com/academy/#_ga=2.43979685.109092771.1525695767-794221708.1524759511


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
cancel
Showing results for 
Search instead for 
Did you mean: