0

I am trying to design a simple Coded UI tests that access the two following functions. Currently they are written with the CUITe framework but I see the same issue when using Coded UI code.

I have a test case which first calls GLJEEnterDescription, then calls GLJEEnterNotes. When the test runs, GLJEEnterDescription is manipulated and BOTH strings passed into the functions are entered into it. Nothing is ever entered into GLJEEnterNotes. I have checked and rechecked and the properties for the controls are correct.

The only difference between the two controls is GLJEEnterDescription is a standard single line text box and GLJEEnterNotes is a custom (derived from standard) multiline text box. Any thoughts on why I would not be able to access and use the GLJEEnterNotes text box but not the GLJEEnterDescription text box? Below is my functions called from the Coded UI tests:

 public void GLJEEnterDescription(string JEDescription)
 {
    akwindow.Find<WinEdit>(By.ControlName("txtJEDescription")).Text = JEDescription;
 }

 public void GLJEEnterNotes(string JENotes)
 {
    akwindow.Find<WinEdit>(By.ControlName("txtMultiJENotes")).Text = JENotes;
 }
Brian
  • 5,069
  • 7
  • 37
  • 47
Dewayne Pinion
  • 41
  • 2
  • 10
  • When you say a 'custom' text box, do you mean that it is the `multi line` text box built into the IDE for VS or is this a control that you, or another company made? As in, a user control. – Brian Jan 21 '16 at 20:22
  • Hey Brian, thanks for responding. It is a multiline text box, but it was created by a company, not sure why as there doesn't seem to be any extra functionality. When I look at the designer file I see this: internal CustomControls.CompanyNameTextboxMultiLine txtMultiJENotes; – Dewayne Pinion Jan 21 '16 at 20:56
  • Are you sure that you are switching focus to your second text box (GLJEEnterNotes) while the code is executing? Meaning, does your code see the second text box? – Brian Jan 21 '16 at 20:59

1 Answers1

0

You most likely need to specify more search criteria for those controls.

Ideally, I would recommend trying to use control ID's or even AutomationID's for your controls. These are the HIGHEST priority for the search algorithm Like in This Post

var textBox = new WinEdit(yourAppWindow);
textBox.SearchProperties.Add(WinEdit.PropertyNames.Name, "txtMultiJENotes");
textBox.SearchProperties.Add(WinEdit.PropertyNames.LineCount, "1");

else you might have to use FindMatchingControls and cycle each control for the right things you want.

Community
  • 1
  • 1
Michael Rieger
  • 472
  • 9
  • 18
  • Thanks to everyone for the replies so far. The odd thing is when the control has an actual "Name" property (which seems to refer to a value in .Text property), then the Name property works fine. However, if I have to depend on ControlName as in my code above, it rarely finds the control. All of my Control IDs seem to be 0. Where is that value set? I created a simple winform application, added a textbox control to it and did not see a property that would equate to a control ID? Automation IDs are not available as this is a winforms app and does not implement WPF controls. – Dewayne Pinion Jan 27 '16 at 20:04