passing enter through keypress event is not working as expected

2 posts, 0 answers
  1. Abc
    Abc avatar
    5 posts
    Member since:
    Aug 2014

    Posted 07 Sep 2014 Link to this post


    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");
                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)

                    //  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);

  2. Ivaylo
    Ivaylo avatar
    749 posts

    Posted 11 Sep 2014 Link to this post

    Hello Mamta,

    I am sorry you are experiencing this behavior. However by providing me only the code I am not able to investigate further. This is a standard key press method which is supposed to work without any issues. I have tested it on my end and it is working fine.

    Please make sure you are using the latest Test Studio (version 2014.3.903) and give it a try. If you continue experiencing the behavior please provide me with the test and the application so I can assist you further.

    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top