Forum Discussion

ChrisMac's avatar
ChrisMac
Contributor
13 years ago

SetFocus producing an error in the log report.

Hello -



I have a class/control called UltraListView that I select items from. Unfortunately, the only way I can get TC to click an item within is to use a SetFocus method like:


Aliases.catalogUltraListView.SetFocus


The minor downside is in the log after the script has run there is an error listed: "The window cannot get focus."


So, TC is telling me that the SetFocus method failed, yet it succeeded in that TC was able to select an item in the UltraListView control because of the use of SetFocus. What I'd like to do is either surpress the error message or find an alternate to SetFocus. Thanks in advance.


Chris

12 Replies

  • Hi Chris,


    TestComplete provides extended support for Infragistics UltraListView controls. It provides special methods and properties that let you perform various operations over the controls. For example, you can use the extended ClickItem method to simulate a mouse click on a specified list item. For more information, please read http://smartbear.com/support/viewarticle/11643/ in the online documentation.

  • Hello Margaret



    I've read the documentation you referenced. The Infragistics Controls Support plug-in is installed. The ClrFullClassName property name of this obect is Infragistics.Win.UltraWinListView.UltraListView and is already listed in the Infragistics Controls | UltraListView group of my project’s Object Mapping options. Thus I'm able to use methods like ClickItem. The issue (and again it's more of an annoyance than anything else) that still persists is that when using SetFocus:


    Aliases.catalogUltraListView.SetFocus


    An error appears in the log: "The window cannot get focus."


    Perhaps it's a timing issue in that the catalogUltraListView object isn't ready to be focused. I'll try and put a delay before it and see if that does anything.


    Chris

  • Hi Chris,


    Does the same error occur if you try to call the SetFocus method for other controls on the form?


    Also, to help us investigate the problem, please follow the steps below:


    1. Paste the following code to your script after the SetFocus method call:




    Log.Picture(Sys.Desktop);

    Log.Message(Sys.Desktop.FocusedWindow().Handle) ;

    Log.Message(Sys.Desktop.FocusedWindow().FullName);


    2. Run the test.


    3. After the test run is over, capture a screenshot of the test log and send it to us.

  • Hi Margaret,



    I've incorporated the code below into one of my scripts and uploaded a screenshot of the log file after it ran. I use VBScipt not JScript so I'm not sure if the syntax is correct. Anyway, check out the screenshot of the log file.


    Log.Picture(Sys.Desktop)

    Log.Message(Sys.Desktop.FocusedWindow().Handle)

    Log.Message(Sys.Desktop.FocusedWindow().FullName)


    Although I'm running a keyword test, here's the code I used (or would use if I converted the keyword test to a script:


      Call Aliases.vendorComboBox.SetFocus

      Call Aliases.vendorComboBox.ClickItem("VENDOR 9")


    Your question: Does the same error occur if you try to call the SetFocus method for other controls on the form?


    Yes, the example above is a combo-box.

  • Hi,


    As far as I can see from the screenshot, when TestComplete tries to set a focus to the combo box, the application handles this and sets the focus to the WinFormsObject("buttonFindLibItems") object. It is difficult to understand why this happens without the tested application. Could you please send us the application under test and the test project you are using via the Contact Support form?

    • roytberA's avatar
      roytberA
      Occasional Contributor

      Hi,

       

      I am having the same issue now,  the object got focus and the test is running fine but the error message says "Unable to find the object SetFocus. "  

       

      When using SetFocus() with window(code below), there is no error message.

      Aliases.browser.BrowserWindow3.SetFocus();

       

       

      Here is my code, I have tried the solution mentioned in this post. The delay doesn't work, and FullName is the name of the object that got focused.  How do I disable the error message??

       

      aqUtils.Delay (2000, "delay to click");
      globalObjects.chooseAfile.SetFocus();
      Log.Message(Sys.Desktop.FocusedWindow().FullName);

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        roytberA wrote:

        Hi,

         

        I am having the same issue now,  the object got focus and the test is running fine but the error message says "Unable to find the object SetFocus. "  

         

        When using SetFocus() with window(code below), there is no error message.

        Aliases.browser.BrowserWindow3.SetFocus();

         

         

        Here is my code, I have tried the solution mentioned in this post. The delay doesn't work, and FullName is the name of the object that got focused.  How do I disable the error message??

         

        aqUtils.Delay (2000, "delay to click");
        globalObjects.chooseAfile.SetFocus();
        Log.Message(Sys.Desktop.FocusedWindow().FullName);


        Note that the OP is a different general source of the issue and is also 4 years old.  There have been numerous updates to TestComplete since then as well as different ways of handling things.  The original post is in a desktop application where as your situation seems to involve web applications.  

         

        I have a question concerning your post... you are trying to set focus on the browser window instead of some component or page within your web application.  What are you intending to achieve?  Please describe what you are trying to implement and any information such as application type (WEB vs Desktop), technologies used in the app, screenshots of the objects in question using Object Spy and/or object browser, etc.