-1

I tried finding the element using Get but it does not work, thats why i treid with GetElement method

I am trying to enter text in an textbox element found using GetElement in teststack white using C#

i want to know how to cast the automation element to UIitem so that i can do enter() or click operation on that element

var all = appWindow.GetElement(SearchCriteria.ByControlType(ControlType.ComboBox)
    .AndByText("Model collapsed"));
var element = all.FindFirst(TreeScope.Children, 
    new PropertyCondition(AutomationElement.NameProperty, "Edit Box collapsed"));
element.enter("");

when i do element.enter or click it gives error, i think i need to cast it or is there any other way where i can achieve this. Thank you.

  • anyone has any solution – Dominic May 20 '19 at 19:57
  • var all = appWindow.GetElement(SearchCriteria.ByControlType(ControlType.ComboBox).AndByText("Model collapsed")); var element = all.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "Edit Box collapsed")); TextBox textBox = new TextBox(element, appWindow.ActionListener); textBox.SetValue(textValue); I am able to locate the textbox now but i am getting {"Operation cannot be performed."}. I have tried .enter("") but no luck same error.. – Dominic May 20 '19 at 20:40

1 Answers1

0

After using the below code i was able to enter text.

var all = appWindow.GetElement(SearchCriteria.ByControlType(ControlType.ComboBox)
.AndByText(parentValue));
 var element = all.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, childValue));
                TextBox textBox = new TextBox(all, appWindow.ActionListener);

 TestStack.White.InputDevices.AttachedKeyboard keyboard = appWindow.Keyboard;
                textBox .Click();
                keyboard.Enter("test");