private void SetValueButton_Click(object sender, RoutedEventArgs e) { // TODO: create an action to get the focusable control from the driver on the device List<ElementInfo> list = ((IWindowExplorer)mAndroidADBDriver).GetVisibleControls(null); // get from the list only text Edit foreach (ElementInfo EI in list) { if (EI.ElementType == "android.widget.EditText") // check if it will work on all apps, might need to rethink { ObservableList<ControlProperty> props = EI.GetElementProperties(); ControlProperty cp = (from x in props where x.Name == "focused" select x).FirstOrDefault(); //FIXME: temp just to try, need to get the best locator for element. ControlProperty cpresourceid = (from x in props where x.Name == "resource-id" select x).FirstOrDefault(); if (cp.Value == "true") { // mDeviceViewPage.AddTextBox() ActUIElement a = new ActUIElement(); a.ElementLocateBy = eLocateBy.ByResourceID; a.ElementType = eElementType.TextBox; a.ElementAction = ActUIElement.eElementAction.SetText; // Need to set value in both since sending direct to driver // a.ElementLocateValue = cpresourceid.Value; a.GetOrCreateInputParam(ActUIElement.Fields.ElementLocateValue).ValueForDriver = cpresourceid.Value; a.GetOrCreateInputParam(ActUIElement.Fields.Value).ValueForDriver = SetValueTextBox.Text; // a.Value = SendKeysTextBox.Text; mAndroidADBDriver.RunAction(a); if (IsRecording) { ControlProperty desc = (from x in props where x.Name == "content-desc" select x).FirstOrDefault(); if (string.IsNullOrEmpty(desc.Value)) { desc = cpresourceid; } a.Description = "Set '" + desc.Value + "' value to '" + SetValueTextBox.Text + "'"; a.GetOrCreateInputParam(ActUIElement.Fields.Value).Value = SetValueTextBox.Text; a.GetOrCreateInputParam(ActUIElement.Fields.ElementLocateValue).Value = cpresourceid.Value; mBusinessFlow.AddAct(a); } return; } } } }