This is a migrated thread and some comments may be shown as answers.

passing enter through keypress event is not working as expected

1 Answer 82 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Abc
Top achievements
Rank 1
Abc asked on 07 Sep 2014, 03:10 PM
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);
                
            }

           .
        }
        

1 Answer, 1 is accepted

Sort by
0
Ivaylo
Telerik team
answered on 11 Sep 2014, 06:48 AM
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.

Regards,
Ivaylo
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Abc
Top achievements
Rank 1
Answers by
Ivaylo
Telerik team
Share this question
or