I would like to test to Outlook application and send an email to me by using White Stack framework. I implemented code who click on 'New Item' and after that the new window appears. I want to type a my mail to TextBox 'To' but I don't know how get to access to second window 'Untitled - Message (HTML)'. Photo
[TestMethod]
public void mail()
{
var application = Application.Launch(appPatch);
Thread.Sleep(2000);
var window = application.GetWindow(appTitle, InitializeOption.NoCache);
SearchCriteria searchCriteriaNewEmail = SearchCriteria.ByText("New Email");
Button buttonNewEmail = window.Get<Button>(searchCriteriaNewEmail);
buttonNewEmail.Click();
Thread.Sleep(1000);
string windowTitle = "Untitled - Message(HTML)";
var window2 = application.GetWindow(windowTitle, InitializeOption.NoCache);
SearchCriteria searchCriteriaTo = SearchCriteria.ByText("To");
TextBox tbxTo = window2.Get<TextBox>(searchCriteriaTo);
tbxTo.BulkText = "[email protected]";
Thread.Sleep(2000);
window.Close();
}
The "second window" is in the same process id, so with that you can't simply use the
.GetWindow()
method.For MDI applications you should use
MdiChild()
, or if it is a modal window, use.ModalWindow()
on the parent window, or go back to the application then useWindow()
to get the window.I would add that getting the window by it's title is not recommended, since that will change as you type the new title of the e-mail.