This question is locked. New answers and comments are not allowed.
Hi,
I am automating a WPF App wherein after entering lastname and firstname into text fields and then press enter fetches the records based on lastname & firstname entered. But while I am automating this , it enters lastname and firstname but doesn't recognise my enter event & doesn't fetch results.
Below is the code , please help me out where I am going wrong.I have to do it on urgent basis.
WpfApplication wpfApp = Manager.LaunchNewApplication(@"E:\Builds\Build_29August2014\Bin\CARA.Desktop.exe");
wpfApp.GetWindow("Warnung").Find.ByName<Button>(WarnungOk).User.Click();
Thread.Sleep(1000);
Assert.IsTrue(wpfApp.MainWindow.Window.Caption != null);
var row = wpfApp.MainWindow.Find.ByName<DataGrid>("Stations");
var rows = row.RowElements;
var alreadyopenstation = rows.FirstOrDefault(stationRow => stationRow.TextBlockContent.Contains(Environment.MachineName));
var openstation = rows.FirstOrDefault(stationRow => stationRow.TextBlockContent.Contains(Open));
var notopenstation = rows.FirstOrDefault(stationRow => stationRow.TextBlockContent.Contains(NotOpen));
System.DateTime today = System.DateTime.Now;
System.DateTime date = today.AddYears(-30);
if (alreadyopenstation != null || openstation != null || notopenstation != null)
{
wpfApp.MainWindow.Find.ByName<Button>(KassaĆffnenOpenstation).User.Click();
Thread.Sleep(1000);
wpfApp.GetWindow("Warnung").Find.ByAutomationId("btnOk").User.Click();
// string window = wpfApp.MainWindow.Window.Caption;
Assert.IsTrue(wpfApp.MainWindow.Window.Caption != null);
wpfApp.MainWindow.Find.ByAutomationId("txtLastName").User.TypeText(("tom"), 1);
wpfApp.MainWindow.Find.ByAutomationId("txtFirstName").User.TypeText(("rom"), 1);
wpfApp.MainWindow.Find.ByAutomationId("txtFirstName").User.KeyPress(System.Windows.Forms.Keys.Enter, 1);
}
.
}
I am automating a WPF App wherein after entering lastname and firstname into text fields and then press enter fetches the records based on lastname & firstname entered. But while I am automating this , it enters lastname and firstname but doesn't recognise my enter event & doesn't fetch results.
Below is the code , please help me out where I am going wrong.I have to do it on urgent basis.
WpfApplication wpfApp = Manager.LaunchNewApplication(@"E:\Builds\Build_29August2014\Bin\CARA.Desktop.exe");
wpfApp.GetWindow("Warnung").Find.ByName<Button>(WarnungOk).User.Click();
Thread.Sleep(1000);
Assert.IsTrue(wpfApp.MainWindow.Window.Caption != null);
var row = wpfApp.MainWindow.Find.ByName<DataGrid>("Stations");
var rows = row.RowElements;
var alreadyopenstation = rows.FirstOrDefault(stationRow => stationRow.TextBlockContent.Contains(Environment.MachineName));
var openstation = rows.FirstOrDefault(stationRow => stationRow.TextBlockContent.Contains(Open));
var notopenstation = rows.FirstOrDefault(stationRow => stationRow.TextBlockContent.Contains(NotOpen));
System.DateTime today = System.DateTime.Now;
System.DateTime date = today.AddYears(-30);
if (alreadyopenstation != null || openstation != null || notopenstation != null)
{
wpfApp.MainWindow.Find.ByName<Button>(KassaĆffnenOpenstation).User.Click();
Thread.Sleep(1000);
wpfApp.GetWindow("Warnung").Find.ByAutomationId("btnOk").User.Click();
// string window = wpfApp.MainWindow.Window.Caption;
Assert.IsTrue(wpfApp.MainWindow.Window.Caption != null);
wpfApp.MainWindow.Find.ByAutomationId("txtLastName").User.TypeText(("tom"), 1);
wpfApp.MainWindow.Find.ByAutomationId("txtFirstName").User.TypeText(("rom"), 1);
wpfApp.MainWindow.Find.ByAutomationId("txtFirstName").User.KeyPress(System.Windows.Forms.Keys.Enter, 1);
}
.
}