Unable to find window (WPF)

1 Answer 36 Views
General Discussions
Hendrik
Top achievements
Rank 1
Iron
Hendrik asked on 09 Oct 2024, 09:58 AM

Hi,

I've created a simple test for a WPF application that clicks a button in my main window to open another window and then clicks a button in this window. Half of the time the test executes as expected, half of the time it fails, because the window was not found. I added a delay before clicking the second button to make sure, that the window is fully loaded. The title of the window is always the same.

I've tried to create a test like this for another window, but there I have the same issue.

Why is the Test Studio not able to find the window and is there anything I can do to fix this? 

 

This are the logs:

Overall Result: Fail
------------------------------------------------------------
'09.10.2024 11:40:43' - Executing test: '10 - Storage Overview', path: 'Overviews\10 - Storage Overview.tstest.'
'09.10.2024 11:40:43' - Using .Net Runtime version: '4.0.30319.42000' for test execution. Build version is '2024.3.813.1'.
'09.10.2024 11:40:43' - Starting execution....
'09.10.2024 11:40:47' - Detected custom code in test. Locating test assembly: 3S_Tests.dll.
'09.10.2024 11:40:47' - Assembly Found: C:\TestStudio\3S_Tests\bin\3S_Tests.dll
'09.10.2024 11:40:47' - Loading code class: '_S_Tests._0___Storage_Overview'.
------------------------------------------------------------
------------------------------------------------------------
'09.10.2024 11:40:47' - Using 'C:\MLM Apps\3S Debug\ProbenverwaltungV3.exe' application.
'09.10.2024 11:40:57' - 'Pass' : 1. Click BtGenerelOverviewCopyButton
'09.10.2024 11:41:02' - 'Pass' : 2. Wait for '5000' msec.
'09.10.2024 11:42:03' - 'Fail' : 3. Desktop command: LeftClick on HeaderButtonRadtogglebutton
------------------------------------------------------------
Failure Information: 
~~~~~~~~~~~~~~~
Unable to find the window 'General Overview' inside application 'C:\Apps\3S Debug\ProbenverwaltungV3.exe'
---- Current Windows: ----
--------------------------

InnerException:
System.Exception: Unable to find the window 'General Overview' inside application 'C:\Apps\3S Debug\ProbenverwaltungV3.exe'
---- Current Windows: ----
--------------------------
 ---> System.TimeoutException: Wait for condition has timed out
   bei ArtOfTest.Common.WaitSync.CheckResult(WaitSync wait, String extraExceptionInfo, Object target)
   bei ArtOfTest.Common.WaitSync.For[T](Predicate`1 predicate, T target, Boolean invertCondition, Int32 timeout, WaitResultType errorResultType)
   bei ArtOfTest.Common.WaitSync.For[T](Predicate`1 predicate, T target, Boolean invertCondition, Int32 timeout)
   bei ArtOfTest.Common.WaitSync.For[T](Predicate`1 predicate, T target, Int32 timeout)
   bei ArtOfTest.WebAii.Wpf.WpfApplication.WaitForWindow(String caption, Int32 timeout)
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei ArtOfTest.WebAii.Wpf.WpfApplication.WaitForWindow(String caption, Int32 timeout)
   bei ArtOfTest.WebAii.Design.Execution.ExecutionEngine.ExecuteStep(Int32 order)
------------------------------------------------------------
'09.10.2024 11:42:03' - Detected a failure. Step is marked 'ContinueOnFailure=False' aborting test execution.
------------------------------------------------------------
'09.10.2024 11:42:03' - Overall Result: Fail
'09.10.2024 11:42:03' - Duration: [1 min: 15 sec: 234 msec]
------------------------------------------------------------
'09.10.2024 11:42:03' - Test completed!

1 Answer, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 10 Oct 2024, 10:39 AM

Hi Hendrik,

I will need some additional information in order to investigate the issue. Please, share the complete failure details for one of the failing runs - you can use the Export button in the failure section to get a zipped folder with all these. 

Other than that you can try to increase the timeout between the two action steps. Currently you use 5 seconds, so you can set it to 7 or 8 seconds and observe if the consistency during execution is improved. If the failures are still too large amount, increase the execution delay to 10-11 seconds.

Since you are saying the test runs successfully for half of the executions I believe this is some sort of timing issue. I hope the failure details will help in sorting out what otehr approach can be used to make the tests more consisent. 

Thank you for your time in advance.

Regards,
Elena
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Hendrik
Top achievements
Rank 1
Iron
commented on 10 Oct 2024, 02:43 PM

Hi Elena,

I've increased the delay to 30 seconds, but the tests are still failing. I can see that the window opens in time, so I don't think it's a timing issue. 

Regards,

Hendrik

Elena
Telerik team
commented on 14 Oct 2024, 07:36 AM

Hi Hendrik, 

Thanks for following up with the failure details.

Let me sort out something about the test run presented in the failure - was the window opened during that run? 

I wonder what was the actual state because the ImageOnFailure shows the main screen and no additional window as in the expected state image. 

You also reported that there are some test runs in which the window gets opened as expected and the click step in that new window is executed successfully. Therefore I want to sort out if the new window gets opened when the test fails reporting the window cannot be found. Or, the actual issue is that the click action which opens up the window is not always performed correctly.

If it turns out that the issue is in the click step, let's check what are the previous steps in the main test. Based on the log I see the steps we look into are a separate test used as a step. So, I need to know what are the previous steps executed. You can share the execution log for reference. 

Thank you for your cooperation once again.

Regrads,
Elena

Hendrik
Top achievements
Rank 1
Iron
commented on 14 Oct 2024, 07:49 AM

Hi Elena,

the window is open everytime and it's in front of the main window.

And I've only performed one test that clicks on the button in the main window, waits and then clicks another button in the new window. There are no previous steps.

Regrads,

Hendrik

Elena
Telerik team
commented on 14 Oct 2024, 03:32 PM

Hi Hendrik,

Excuse me for any possible misunderstanding but when I can't test the issue on my end, I am trying to collect as much details as possible to help me in analsying the case. 

So, having in mind that the test passes for half of the executions I believe that there is some sort of missynchronization which causes the misbehavior and causes the test to fail. Let's try the following: 

  1. Select the test in question and hit the Record button. This launches the tested application and attaches the recorder to it. When present pause the recorder. 
  2. Select the first step of the test and use the partial run option Run->From Here - this executes the test in the test starting from the selected step. In this case the complete test will be executed, but the main point is that the application is already started. 
  3. What is the outcome of this test run? Does it fail again?
    If so, please, collect the step failure details for that run and send these over. 
  4. And if it executes successfully, then insert an execution delay of a second or two as a first step in the test. This will allow the application to be launched and the Test Studio process to be injected correctly. 
  5. Close the active recording session and execute the complete test to check what is the outcome of the test run - is it successful this time? 

I'm looking forward to hearing back from you.

Regards,
Elena

Hendrik
Top achievements
Rank 1
Iron
commented on 15 Oct 2024, 04:08 PM

Hi Elena,

unfortunately the test is still failing. But I tried to create a new test and it took me multiple attempts until the TestStudio attached the recorder to the second window. I tried this for different windows and I waited 1 to 2 minutes for the recorder, but most of the time the recoder-bar did not appear.

I checked the title of the windows, but they don't get changed.

And there are splashscreens that are displayed while the window is loading, can something like this cause the issue?

 

Thank you for your help!

Regards,

Hendrik

Elena
Telerik team
commented on 18 Oct 2024, 09:01 AM

Hi Hendrik, 

Thanks for sharing these additional notes. Please, take the time for the below steps:

  1. Generate the application log during the attempt to record the same scenario once again. 
  2. Generate the application log during the test run - I know I requested the execution log already, but the application one contains additional info which may be of further help for us.
  3. Share any details on that splash screen used while launching the new windows. What is the purpose of these? Does the process of the application remains the same? Or the new windows are sort of another application? 
  4. If you don't mind to share a short video in the public forum post, please, capture one during the test run and share it along.

Thank you for your time once again.

Regards,
Elena

Hendrik
Top achievements
Rank 1
Iron
commented on 18 Oct 2024, 02:07 PM

Hi Elena,

I think my problem is solved: I've clicked on "Help->Enable Logging", to create the logs you ask for. After logging was enabled I was not able to reproduce both issues, the recorder not getting attached and the failing tests. 

I created a test list with 3 test and run it multiple times with logging dis- or enabled and all tests failed when it was disabled. When logging was enabled 23/24 test were successful.

Do you have an explanation for this? Thank you!

 

Regards,

Hendrik

Elena
Telerik team
commented on 21 Oct 2024, 09:22 AM

Hi Hendrik, 

Thanks for your prompt response.

With these new details we assume that the issue is specific to the tested application and it is sort of a race condition in how these windows are recognized by Test Studio. Obviously the enabled logging brings some minimal delay (it is about miliseconds) which brings the magic and the application window is found correctly. 

I have to say that there isn't much we can do in this case. The only way of debugging the issue is if we have the tested application on our end. And even that way we can't guarantee that the misbehavior will be reproduced as it might be also related to the specific machine. In any case this type of issues are usually addressed with a possible blind fix. 

Having said the above you can use the enabled logging as a workaround to continue recording and executing tests. If you want the issue to be investigated further we will need a copy of the application. But as this is a public forum post, I will recommend to post a private thread for this. 

Thank you for your continuous cooperation in our conversation.

Regards,
Elena

Tags
General Discussions
Asked by
Hendrik
Top achievements
Rank 1
Iron
Answers by
Elena
Telerik team
Share this question
or