my general setup: we've written a little excel importer with a small gui, that allows non programmers to write and execute gui-tests with commands like "Button.Click". The underlying framework is TestStack.White. After importing the excel file and some other user-intercations the test starts inside a System.ComponentModel.BackgroundWorker, which works fine, as long as i do not look (or even interact with) elements that contain a huge number of childelements.
But as soon as i interact with an TestStack.White.UIItems.WindowItems.Window or an TestStack.White.UIItems.UIItemContainer that has a lot of elements the testexecution just ends.
With interact i mean everything from simple stuff like a not null check or an assignment into a local variable or stuff like asking for it's childcount. Some examples that end the testexecution: 1)
if(theElement != null){ //everything after this line does not happen. The operator doesn't seem to be overloaded
doStuff(); //it never reaches this point
}
2)
UIItemContainer pointOfInterest = theElement; //everything after this line does not happen
3)
System.Diagnostics.Debug.WriteLine("AmountOfElements: " + UIAnchor.Items.Count); //the output doesn't come. everything after this line does not happen
In windows without hundreds of elements, all three examples work as intended.
By a lot of elements i mean e.g. a Window that has a ScrollView inside, which has a table with dozens or even hundreds of entries, where every entry consists of 3-4 columns with text or a checkbox or something like that.
The Backgroundworkers RunWorkerCompleted and also the Disposed doesn't get called. I get no Exception at all, even with purposely placed try/catch blocks i get nothing out of it. The debugger reaches the line that causes the problem and that's it. Nothing comes afterwards, even with 1h of waiting.
Instead i get just a couple of different "The thread {some hex id} has exited with code 259 (0x103)." in the output window of Visual Studio. This is from my last test execution:
The thread 0x830 has exited with code 259 (0x103).
The thread 0xfc0 has exited with code 259 (0x103).
The thread 0xc04 has exited with code 259 (0x103).
As far as i've understood this message, it means that the Thread is still alive. https://mcmap.net/q/326790/-why-am-i-seeing-multiple-quot-the-thread-0x22c8-has-exited-with-code-259-0x103-quot-messages
If i go into the debuger to check the content of the element that causes the error, i get timeouts on all elements which came after the Items (the List with the childelements), including the Items.
Also the issue is not (or shouldn't be?) that the main thread ends, as it was the case in this thread: Trying to step through BackgroundWorker code in debug but program ends unexpectedly because the gui is still running fine.
Does anyone have an idea what might be happening here or how to fix this issue?
This is how i start the app:
Application app = TestStack.White.Application.Launch(pathToExeFile);
context.setApp(app); //context is a class with static variables to eas the access to all kind of stuff, so that i access it without having 20 parameters in every method (e.g. Button.Click())
Afterwards the user sets which window he wants to test (which might or might not be a modal window - but in windows without hundreds of elements it works):
foreach (Window win in context.getApp().GetWindows()) {
System.Diagnostics.Debug.WriteLine("###SelectWindow: " + win.Name + " # " + win.PrimaryIdentification + " # " + win.Title);
if (win.Name.Equals(nameOfWindowToTest)) {
System.Diagnostics.Debug.WriteLine("###SelectWindow: gefunden");
context.UIAnchor = win;
System.Diagnostics.Debug.WriteLine("####SelectWindow: Anz Items: " + context.UIAnchor.Items.Count); //this gets called, but is the very last thing the thread does
return null; //does not happen
}
}
context.UIAnchor is theElement mentioned above. Afterwards the methods set by the user (e.g. Button.Click) gets called. Funnily the context.UIAnchor = win and the output of the items.count works.
Update: If i close the app that is to be tested, before i close the testing programm, i get a ElementNotAvaiableException. So the Thread shouldn't be totally dead.