or
Hi,
Environment
- TTF: 2014.3
- Visual Studio 2012
I am finding that I am not seeing the WindowClosed event handler getting called.
I even set things up so that I manually open and close the window; the event handler
does not seem to be fired.
I'm assuming that TTF does not require any special work to be done by the Wpf client
in order to see the event, right?
Hopefully, someone has some ideas and suggestions.
Thanks in advance,
Below is a sample code :
public
class
TestClass {
private
bool
_winClosed;
private
void
WindowClosedEventHandler(
object
sender, EventArgs e)
{
_winClosed =
true
;
}
public
void
CloseWindow()
{
var win = wpfClient.WaitForWindow(
"Header of Window"
, _settings.ExecuteCommandTimeout);
win.WindowClosed += WindowClosedEventHandler;
// subscribe to event
_winClosed =
false
;
win.Window.SetFocus();
while
(!_winClosed)
// wait for event handler to set _winClosed to true
{
Logger.Debug(
"Waiting for win to close"
);
Pause(500);
}
win.WindowClosed -= WindowClosedEventHandler;
// unsubscribe to event
}
...
}
//Use ClassInitialize to run code before running the first test in the class
[ClassInitialize()]
public static void MyClassInitialize(TestContext testContext)
{
}
/// <
summary
>
/// Use TestInitialize to run code before running each test
/// Initializes WebAii manager to be used by the test case.
/// If a WebAii configuration section exists, settings will be
/// loaded from path. Otherwise, will create a default settings
/// object with system defaults.
///
/// Note: We are passing in a delegate to the VisualStudio
/// testContext.WriteLine() method in addition to the Visual Studio
/// TestLogs directory as our log location. This way any logging
/// done from WebAii (i.e. Manager.Log.WriteLine()) is
/// automatically logged to the VisualStudio test log and
/// the WebAii log file is placed in the same location as VS logs.
///
/// If you do not care about unifying the log, then you can simply
/// initialize the test by calling Initialize() with path parameters;
/// that will cause the log location to be picked up from the config
/// file if path exists or will use the default system settings (C:\WebAiiLog\)
/// You can also use Initialize(LogLocation) to set a specific log
/// location for this test.
/// </
summary
>
[TestInitialize()]
public void MyTestInitialize()
{
#region WebAii Initialization
// Pass in 'true' to recycle the browser between test methods
Initialize(false, this.TestContext.TestLogsDir, new TestContextWriteLine(this.TestContext.WriteLine));
// Set the current test method. This is needed for WebAii to discover
// its custom TestAttributes set on methods and classes.
// This method should always exist in [TestInitialize()] method.
SetTestMethod(this, (string)TestContext.Properties["TestName"]);
_telerikBrowser = new TelerikBrowser();
_app = _telerikBrowser.App;
_telerikButton = new TelerikButton(_app);
_telerikTextBox = new TelerikTextBox(_app);
_telerikTextBlock = new TelerikTextBlock(_app);
#endregion
//
// Place any additional initialization here
//
}
// Use TestCleanup to run code after each test has run
[TestCleanup()]
public void MyTestCleanup()
{
//
// Place any additional cleanup here
//
#region WebAii CleanUp
// Shuts down WebAii manager and closes all browsers currently running
// after each test. This call is ignored if recycleBrowser is set
this.CleanUp();
#endregion
}
//Use ClassCleanup to run code after all tests in a class have run
[ClassCleanup()]
public static void MyClassCleanup()
{
// This will shut down all browsers if
// recycleBrowser is turned on. Else
// will do nothing.
ShutDown();
}
#endregion
/// <
summary
>
/// Method to add the different values for selecting the PDB by selexting different control in TelerikCommon
/// </
summary
>
[TestMethod]
public void AddNewPdbSelector_ValidPDB_MethodSuccessful()
{
String PDB = "Athene1_DB";
System.Threading.Thread.Sleep(4000);
//click the plussy plus sign
_telerikButton.ClickButton(ControlsDefinition.PdbAddButton);
//refresh
_app.RefreshVisualTrees();
//populate controls
_telerikTextBox.PutValueToTextBox(ControlsDefinition.PdbHostNameAssociatedLabelText, "AB-M4500", true);
_telerikTextBox.PutValueToTextBox(ControlsDefinition.PdbInstanceNameAssociatedLabelText, " ", true);
_telerikTextBox.PutValueToTextBox(ControlsDefinition.PdbInstancePortAssociatedLabelText, "0", true);
_telerikTextBox.PutValueToTextBox(ControlsDefinition.PdbNameAssociatedLabelText, "Athene1_DB", true);
// log a message
//click the button
_telerikButton.ClickButton(ControlsDefinition.PdbCommitButton, 4000);
//refresh
_app.RefreshVisualTrees();
}