Forum Discussion

ehendin's avatar
ehendin
New Contributor
7 years ago
Solved

Problem with TestComplete locating a pop up

Hi Everyone,

I have been trying to find a solution or even a workaround for an issue with my TestComplete Keyword mode script, which seems unable to find a pop up window.   I actually see the application is launching a pop up with the name "Scheduler" but I believe since I did not create the popup I cannot reference it by that name.


In any event I tried looking at this link but there is still a missing piece for me.

https://support.smartbear.com/testcomplete/docs/testing-with/running/handling-errors/object-not-found/cannot-obtain-window.html

 

I am able to select the window with the object spy.  However, here is what I am doing incorrectly - I try to use setFocus() as a code snippet to change the focus to the popup window... In Object Spy the Window is named "BrowserWindow(1)" but "BrowserWindow(1).setFocus() does not work (not surprisingly).

 

In Selenium there is a way to "getWindowHandles()" to get all open windows and then you switchTo() and reference the window you want.


Here I am at a loss as to how to resolve this... I was trying to even look up how to workaround this by just using JavaScript but again I am trying to locate a window that is open that was launched as a result of a click action in the application I am testing. (in JS it is fairly straightforward if you want to reference a popup you yourself created, but that is not the case here) 

 

My object map has the element but basically I want to switch the focus to the popup - enter some data in input fields on the popup, and then close the popup via click of another button (if I can switch the focus the rest should be easy).

 

Thanks in advance for any suggestions you may have... I attached some screenshots.

 

(~ (TestComplete Version: 12.42.3048.7 x64 | Firefox 52.4.1 (64-bit) ~)

  •  

    Try to call snippet: Alias.browser.BrowserWindow(1).SetFocus();

     

    Does it help?

     

     

6 Replies

  • baxatob's avatar
    baxatob
    Community Hero

    Hi!

     

    Try to interact with Page object instead of BrowserWindow:

     

    • ehendin's avatar
      ehendin
      New Contributor

      Thanks, baxatob!  I am finding I am going down quite the rabbit hole with this.
      Can you give me an example syntax for doing this?  TestComplete seems to want me to "define" the Page object.

      When you say, "Try to interact with Page object instead of BrowserWindow"

      I understand I can look at the page object and work with its methods... but I find that it tells me that the page object is undefined, and I am clearly not either referencing it properly or defining it to TestComplete's satisfaction.

       

      Conceptually I am trying to locate the window and change the focus to the window so I can then perform some actions on that window.  I could also try to locate all the children of "Sys" that are browser windows, and pick the one with the URL in question, but it seems like that is not how TestComplete "works".

       

      Part of the problem may be that I am in keyword mode where I feel like my low-level control of what is happening may be limited, but I have only used the script mode for piecemeal things.

       

      Thanks!

      Erik

       

      https://support.smartbear.com/testcomplete/docs/reference/test-objects/controls/web/general/page/methods.html

      https://developer.mozilla.org/en-US/docs/Web/API/Window

      • baxatob's avatar
        baxatob
        Community Hero

         

        Try to call snippet: Alias.browser.BrowserWindow(1).SetFocus();

         

        Does it help?