Forum Discussion

saguirre's avatar
saguirre
Occasional Contributor
7 years ago

"Waiting for Button Object" occurs AFTER the button has already been pressed for a Java Swing app

Greetings,

 

I have a keyword test for a Java Swing application that is working perfectly fine. However, I am noticing behavior that I don't understand that I believe is making the execution time of the test unnecessarily long. There are several dialog boxes that pop-up in the app during test execution. When I am done interacting with the dialogs, I am closing them by doing a ClickButton operation on the "Close" buttons on each dialog. These buttons are javax.swing.JButtons. TestComplete is correctly clicking on the buttons and the dialogs are dismissed, but then, strangely, I can see in the "indicator" a message like, "Waiting for [Button] Object" and the test paused for several seconds. Normally, I am used to seeing such pauses BEFORE interacting with components. Anyway, I feel like, when you add up all the times that this happens in my test, it is costing me about half a minute (in a test that runs in three minutes). Does anyone have any answers for why this is happening, or what I can do to prevent it from happening so that I can reduce my test execution time?

  • OK, so SmartBear did find me a solution that worked fine. It was actually a bug in TestComplete, and they provided me with a patch that fixed the behavior. After applying the patch, TestComplete not longer "waits" for buttons it already clicked. It shaved off quite a bit of execution time from my test. The patch they gave me was not in that recent big update, but they assured me that the fix will be in a future release.

  • saguirre's avatar
    saguirre
    Occasional Contributor

    OK, so SmartBear did find me a solution that worked fine. It was actually a bug in TestComplete, and they provided me with a patch that fixed the behavior. After applying the patch, TestComplete not longer "waits" for buttons it already clicked. It shaved off quite a bit of execution time from my test. The patch they gave me was not in that recent big update, but they assured me that the fix will be in a future release.

  • saguirre's avatar
    saguirre
    Occasional Contributor

    OK, I entered a support ticket for this, but I assume no one else but me can access the ticket, so I won't post the ticket # here.

    • cunderw's avatar
      cunderw
      Community Hero

      Awesome!  Please post any findings or solutions they have. 

  • saguirre's avatar
    saguirre
    Occasional Contributor

    Thanks again. I just might do that (open a support ticket). Could you give me an idea of how to implement your solution in a keyword test? For example what operation would I use to grab the timeout setting?

  • saguirre's avatar
    saguirre
    Occasional Contributor

    Thanks for the suggestion! I was hoping for a solution that didn't involve any coding, though. Like I said, the test runs fine. It is just taking longer than it has to because of the unnecessary waits.

    • cunderw's avatar
      cunderw
      Community Hero

      That solution could definitely be replicated in keyword test. I would recommend opening a support ticket as well though. Something I probable should have done. 

  • cunderw's avatar
    cunderw
    Community Hero

    I have seen this exact behavior in JavaFX before, but not swing. Same type of thing, I have dialog popup that occurs and need to dismiss with the click of a button. The clickButton works and then it waits for the button after the click.

     

    I worked around by caching the current time out settings, setting it to 500 then setting it back.

     

      let tempTime = Options.Run.Timeout;
      try {
        buttonOK.WaitProperty("Exist",true,5000);
        buttonOK.WaitProperty("VisibleOnScreen",true,5000);
        Options.Run.Timeout = 500;
        buttonOK.ClickButton();
      } catch(err) {
        Log.Error("There was an error with the operations. See Additional Information.", err.message + "\n" + err.stack);
      } finally {
        Options.Run.Timeout = tempTime;
      }

    Hacky solution but it works. 

  • saguirre's avatar
    saguirre
    Occasional Contributor

    Screenshot attached. I will also just paste in the related code that was generated.

     

    Aliases.jp2launcher.SecondExemptBankBandsDialog.RootPane.null_layeredPane.null_contentPane.SplitPane.ScrollPane.Viewport.Panel.ExemptSecondBankBands5MaxHours.SetText(ExemptSecondBankBand5MaxHours);
      Aliases.jp2launcher.SecondExemptBankBandsDialog.RootPane.null_layeredPane.null_contentPane.SplitPane.ScrollPane.Viewport.Panel.ExemptSecondBankBands6RangeBegin.SetText(ExemptSecondBankBand6RangeBegin);
      Aliases.jp2launcher.SecondExemptBankBandsDialog.RootPane.null_layeredPane.null_contentPane.SplitPane.ScrollPane.Viewport.Panel.ExemptSecondBankBands6RangeEnd.SetText(ExemptSecondBankBand6RangeEnd);
      Aliases.jp2launcher.SecondExemptBankBandsDialog.RootPane.null_layeredPane.null_contentPane.SplitPane.ScrollPane.Viewport.Panel.ExemptSecondBankBands6HoursToAccrue.SetText(ExemptSecondBankBand6HoursToAccrue);
      Aliases.jp2launcher.SecondExemptBankBandsDialog.RootPane.null_layeredPane.null_contentPane.SplitPane.ScrollPane.Viewport.Panel.ExemptSecondBankBands6MaxHours.SetText(ExemptSecondBankBand6MaxHours);
      Aliases.jp2launcher.SecondExemptBankBandsDialog.RootPane.null_layeredPane.null_contentPane.SplitPane.Panel.ExemptSecondBankBandsConfirmButton.ClickButton();
      //Switch to the Non-Exempt General Options tab.
      Aliases.jp2launcher.TemplateImportDialog.RootPane.null_layeredPane.null_contentPane.Panel.TabbedPane4.ClickTab("Non-Exempt General Options");
      //Populate parameters on the Non-Exempt General Options tab.
      Aliases.jp2launcher.TemplateImportDialog.RootPane.null_layeredPane.null_contentPane.Panel.TabbedPane5.ScrollPane.Viewport.Panel.NonExemptTimesheetSubmittalRemindersComboBox.ClickItem(NonExemptEEtimesheetSubmittalReminder);
      Aliases.jp2launcher.TemplateImportDialog.RootPane.null_layeredPane.null_contentPane.Panel.TabbedPane5.ScrollPane.Viewport.Panel.NonExemptElapsedHoursIncrementTextField.SetText(NonExemptElapsedHrsIncrement);
      Aliases.jp2launcher.TemplateImportDialog.RootPane.null_layeredPane.null_contentPane.Panel.TabbedPane5.ScrollPane.Viewport.Panel.NonExemptGraceTextField.SetText(NonExemptGrace);
  • saguirre's avatar
    saguirre
    Occasional Contributor

    It's a keyword test. Do you want me to generate code from it? Or just take a screenshot?

  • Lets see your code with the ClickButton and a few lines before and after.