/// <summary> /// Stores value of the string to a user-defined variable. /// </summary> /// <param name="sender">The script engine instance (frmScriptEngine) which contains session variables.</param> /// <param name="targetVariable">the name of the user-defined variable to override with new value</param> public static void StoreInUserVariable(this String str, object sender, string targetVariable) { Core.Automation.Commands.VariableCommand newVariableCommand = new Core.Automation.Commands.VariableCommand { v_userVariableName = targetVariable, v_Input = str }; newVariableCommand.RunCommand(sender); }
public override void RunCommand(object sender) { var variableWindowName = v_AutomationWindowName.ConvertToUserVariable(sender); var searchItem = AutomationElement.RootElement.FindFirst (TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, variableWindowName)); if (searchItem == null) { throw new Exception("Window not found"); } var requiredItem = searchItem.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, v_AutomationID)); var newVariableCommand = new Core.Automation.Commands.VariableCommand { v_userVariableName = v_userVariableName, v_Input = requiredItem.Current.Name }; newVariableCommand.RunCommand(sender); }