cancel
Showing results for 
Search instead for 
Did you mean: 

How do I switch between two browser windows?

SOLVED
New Contributor

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 to activate a particular window. But it is not working.

 

I have been searching for information on the most proficient method to do this, yet I'm learning as I go, and I've invested excessively energy attempting to assemble this test. I trust this is a moderately basic kind of test that others have composed previously. Would someone be able to provide me the most ideal approach to this test? Any kind of help would be highly appreciated. Thanks in advance.

5 REPLIES
Community Hero

Re: How do I switch between two browser windows?

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();

...

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Highlighted
Contributor

Re: How do I switch between two browser windows?

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....

New Contributor

Re: How do I switch between two browser windows?

Thanks a lot Alex, I will give it a try.

Community Hero

Re: How do I switch between two browser windows?

@SaravanaKumar_N:
Hi,

 

we also follow the same approach - POM.

Actually, in my reply I talked about page object provided by TestComplete for web pages opened in browsers, but not about Page Object Model pattern.

While you may implement it in your TestComplete code, TestComplete already provides a kind of it via its objects tree of the tested application (visualized in the Object Browser) and Namemapping/Aliases. However, implementation of POM in Selenium and Aliases in TestComplete has a different architecture and may cause unexpected behaviour if used blindly like in code samples for Selenium/Appium/etc. without considering TestComplete's specifics.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Contributor

Re: How do I switch between two browser windows?

I confused your 'page' object with our page object model Smiley Happy

The one we have is test complete version of page object model, we follow that idea but not the entire Selenium framework. Ofcourse tools are different and their strength are different.

Initialy we used this pattern for desktop tool automation, I gone through many ideas here in this forum. We did not find much difficulties, now applied the same kind of logic with our web automation as well with slight changes related to web.

Watch a new Video
Top Kudoed Authors