Forum Discussion

Moulya_p's avatar
Moulya_p
Occasional Contributor
7 years ago

How do I switch between two browser windows?

Hello Everyone,   I have a script where I need to switch back to the previously opened browser window and perform some actions using TestComplete. I tried using the SetFocus() and Focus() method ...
  • AlexKaras's avatar
    7 years ago

    Hi,

     

    Usually, for web testing with TestComplete, you should work with Page object that is a child of the browser process but not with browser windows.

    With this in mind, just refer to the required Page and it should be activated by TestComplete itself.
    E.g.:

    var page1 = Aliases.browser.Page('www.example.com/AdministerUsers/*');

    ...

    // some link/button was clicked that opens new page

    var page2 = Aliases.browser.Page('www.example.com/CommonUsersArea/*');

    ...

    // do something within page2

    ...

    // switch back to page1

    page1.Button('Create new user').Click();

    ...

     

  • SaravanaKumar_N's avatar
    SaravanaKumar_N
    7 years ago

    Yes, we also follow the same approach - POM. And created NameMapping for each page - HomePage, HelpPage, etc.

    Each page can be accessed like - 

    Alaises.webApp.homePage....

    Alaises.webApp.helpPage....