Forum Discussion

lambada's avatar
lambada
Contributor
7 years ago

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 ...
  • tristaanogre's avatar
    tristaanogre
    7 years ago

    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');
    }