Forum Discussion

saleem1990's avatar
saleem1990
New Contributor
5 years ago

How i can verify second browser tab elements and switch back to first browser tab

Hi,

I am working with complete descriptive  . Below is my sample code

Browsers.Item(btChrome).Run("URL")
Set oBrowser = Sys.Browser("*")
Set oPage = oBrowser.Page("*")

 

Set obj= oPage.Find(arrPropNames, arrPropValues, 90, True)

If obj.Exists Then
obj.Click

end if

 

everything is working perfect if i am on single browser window . There is one scenario where if i click link it will open one more window where i need to validate some elements and switch back to first one for further validation

 

.Find not able to recognize objects in second browser window

 

Note :

1.URL is dynamic so i cant use url while creating page object

 any better suggetion without using URL as property

 

2. I should not use name mapping

 

in UFT we have creationtime so we can easily do that but in testcomplete so many complications 

 

 

 

4 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    > Set oBrowser = Sys.Browser("*")
    > Set oPage = oBrowser.Page("*")

    On the human language the first line means this: "Search for any browser running in the system and use the found one from this point on".

    The second line means this: "Using the browser found on the previous step, get any page opened in it and use this page from this point on".

    Considering the above, I hope that it is obvious that some other but not expected browser and page can be found and used when more than one browser with more then one page are open in the system.

    You need to provide exact identification criteria to command TestComplete to search for and use the object that you need for your test.

     

    • saleem1990's avatar
      saleem1990
      New Contributor
      Hi Alex,
      Thanks for reply. Your correct
      Is there any way without using below lines .
      So that I can test multiple browser page validation
      Set oBrowser = Sys.Browser("*")
      Set oPage = oBrowser.Page("*")
      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        > Is there any way without using below lines .

        Not sure I got the question...

        In order for the tool to be able to work with browser and web page they must be somehow specified. The way of specification depends on the tool. As you said, for UFT it is possible to use some property that specifies when the given programmatic object was created.

        TestComplete tries to mimic human user as much as possible. Thus the preferred way of addressing objects for TestComplete is to use those properties that the human end user works with.

        Consider the following manual scenario: I started this test and proceeded to the point where I have two pages opened in the browser. Then I had to switch to do something else and asked you to continue the test.

        Will you deal with creationtime? I bet no. You just will have nothing like that. Will you be able to identify the browser to use, the initial page and second spawned one? I am pretty sure that yes. How will you be able to identify them? Consider how you will do this manually and implement the same logic/identification attributes in your automated code.