public override ScriptsExpression GenRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { string reStr = GetComment(scriptGenerationParams) + NEW_LINE; var re = GenRawRanorexScripts(scriptGenerationParams); if (re == null) { return(null); } re.Expression = reStr + re.Expression; // if procedure, need to validate if (scriptGenerationParams.Color.Equals(PRE_CONDITION_COLOR)) { re.Append(NEW_LINE + getValidation( getScriptAccessRanorexObject(scriptGenerationParams), scriptGenerationParams.SpecNode, getRealAttribute(scriptGenerationParams.SpecNode), RemoveSingleQuote(expression), scriptGenerationParams.ScreenName, scriptGenerationParams.Id, scriptGenerationParams.SpecNode.ToString())); } return(re); }
public static string getScriptAccessRanorexObject(IRanorexScriptGenerationParams _params) { SpecNode nodeAndAttribute = _params.SpecNode; IElement node = nodeAndAttribute.UIElement; string attribute = nodeAndAttribute.Attribute; string re = getScriptAccessRanorexElement(nodeAndAttribute, _params.InstanceName); if (node is AppFolderRanorexElement || node is FolderRanorexElement) { re += ".SelfInfo"; } else { if (attribute == null || attribute.Equals("")) { re += "Info"; } else if (Regex.IsMatch(attribute, "Cell\\s*\\((\\d+?),\\s*(\\d+?)\\)(\\.\\w+)*") || Regex.IsMatch(attribute, "Row\\s*\\((\\d+?)\\)(\\.\\w+)*")) { re += ".Element"; } else { re += "Info"; } } return(re); }
public override ScriptsExpression GenRawRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { string objectElement = getScriptAccessRanorexObject(scriptGenerationParams); string re = GenerateStatement(objectElement); return(new ScriptsExpression(re)); }
public override ScriptsExpression GenRawRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { string value = getValue(expression); if (value == null) { return(null); } string re = "Validate."; re += "Attribute(" + getScriptAccessRanorexObject(scriptGenerationParams) + ", "; re += "\"" + getRealAttribute(scriptGenerationParams.SpecNode) + "\", "; re += "new Regex("; if (expression.StartsWith(ATTRIBUTE_CONTAIN)) { re += "Regex.Escape("; re += "\"" + value + "\")));"; } else if (expression.StartsWith(ATTRIBUTE_NOT_CONTAIN)) { re += "\"^((?!(\"+Regex.Escape("; re += "\"" + value + "\")+\"))(.|\\n))*$\"));"; } return(new ScriptsExpression(re)); }
public override ScriptsExpression GenRawRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { string pathToExeFile = scriptGenerationParams.PathToApp; return(new ScriptsExpression("Host.Local.RunApplication(@\"" + pathToExeFile + "\", \"\", \"\", false);")); }
public override ScriptsExpression GenRawRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { string scripts = getRanorexScriptCapture( getAppFolderObjectElement(scriptGenerationParams.SpecNode.UIElement, scriptGenerationParams.InstanceName), scriptGenerationParams.ScreenName, scriptGenerationParams.Id, scriptGenerationParams.SpecNode.GetNormalizedName()); return(new ScriptsExpression(scripts)); }
public override ScriptsExpression GenRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { string reStr = GetComment(scriptGenerationParams) + NEW_LINE; var re = GenRawRanorexScripts(scriptGenerationParams); re.Expression = SoundWithTryCatch(re.Expression, getRanorexScriptCapture( getAppFolderObjectElement(scriptGenerationParams.SpecNode.UIElement, scriptGenerationParams.InstanceName), scriptGenerationParams.ScreenName, scriptGenerationParams.Id, scriptGenerationParams.SpecNode.GetNormalizedName())); re.Expression = reStr + re.Expression; return(re); }
//full scripts public virtual ScriptsExpression GenRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { string reStr = GetComment(scriptGenerationParams) + NEW_LINE; var re = GenRawRanorexScripts(scriptGenerationParams); if (re == null) { return(null); } re.Expression = reStr + re.Expression; return(re); }
public override ScriptsExpression GenRawRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { string pathToExeFile = scriptGenerationParams.PathToApp; string re = "Host.Local.KillApplications(\"" + pathToExeFile.Substring( pathToExeFile.LastIndexOf(@"\") + 1, pathToExeFile.LastIndexOf(".")) .Replace(@"\", @"\\") + "\");"; return(new ScriptsExpression(re)); }
public override ScriptsExpression GenRawRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { string re = getScriptAccessRanorexElement(scriptGenerationParams.SpecNode, scriptGenerationParams.InstanceName) + ".Element."; Regex pattern1 = new Regex("Get\\s+(?<word>\\w+)"); Match matcher1 = pattern1.Match(expression); if (matcher1.Success) { re += "GetAttributeValue(" + matcher1.Groups["word"] + ");"; } else { LogError(logger, "expression fail :" + expression); } return(new ScriptsExpression(re)); }
public override ScriptsExpression GenRawRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { string re = "Keyboard.Press(\""; var p = ParseExpression(this.expression); int indi = p.Item1; if (indi == 1) { var listActions = p.Item2; for (int fi = 0; fi < listActions.Length; fi++) { string action = listActions[fi].Trim(); re += "{" + replaceReturnChar(RemoveSingleQuote(action)) + "}"; } re += "\");"; } else if (indi == 2) { string[] keys = p.Item2; string leftScript = ""; string rightScript = ""; for (int fi = 0; fi < keys.Length - 1; fi++) { string key = keys[fi].Trim(); leftScript += "{" + key + " down}"; rightScript = "{" + key + " up}" + rightScript; } re += leftScript; string lastKey = keys[keys.Length - 1].Trim(); re += "{" + lastKey; if (Regex.IsMatch(lastKey, "\\w")) { re += "key"; } re += "}" + rightScript; re += "\");"; } else { LogError(logger, expression); return(null); } return(new ScriptsExpression(re)); }
public override ScriptsExpression GenRawRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { string value = null; string re = getScriptAccessRanorexObject(scriptGenerationParams); re += ".SetAttributeValue(\"" + getRealAttribute(scriptGenerationParams.SpecNode) + "\", \""; if (checkValidValueExpress(expression)) { value = formatValue(expression); value = replaceReturnChar(value); } //rest else { return(null); } re += value + "\");"; return(new SetScriptExpression(re, value)); }
public override ScriptsExpression GenRawRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { string re = getScriptAccessRanorexElement(scriptGenerationParams.SpecNode, scriptGenerationParams.InstanceName) + "Info."; if (expression.StartsWith(WAIT_EXIST)) { re += "WaitForExists("; re += expression.Substring(WAIT_EXIST.Length).Trim(); re += ");"; } else if (expression.StartsWith(WAIT_NOT_EXIST)) { re += "WaitForNotExists("; re += expression.Substring(WAIT_NOT_EXIST.Length).Trim(); re += ");"; } else { LogError(logger, "not handled for expression: " + expression); } return(new ScriptsExpression(re)); }
public static ScriptsExpression GetRawRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams, string expression) { string value = null; if (checkValidValueExpress(expression)) { value = formatValue(expression); value = replaceReturnChar(value); } else { string log = "[Error] Expression: " + expression + " at sheet " + scriptGenerationParams.ScreenName + ", testcase #" + scriptGenerationParams.Id + NEW_LINE + "Invalid expression: " + expression; scriptGenerationParams.MyLog.Error(log); logger.Error(log); return(null); } string re = "Validate.Attribute(" + getScriptAccessRanorexObject(scriptGenerationParams) + ", "; re += "\"" + getRealAttribute(scriptGenerationParams.SpecNode) + "\", \"" + value + "\"" + ");"; return(new ScriptsExpression(re)); }
public override ScriptsExpression GenRawRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { string re = "Mouse.MoveTo(" + getScriptAccessRanorexElement(scriptGenerationParams.SpecNode, scriptGenerationParams.InstanceName) + ");" + NEW_LINE + "Mouse.ButtonDown(System.Windows.Forms.MouseButtons.Left);" + NEW_LINE + "Mouse.MoveTo("; Regex pattern1 = new Regex("Drop\\s+(?<word>\\w+)"); Regex pattern2 = new Regex("Drop\\s*\\((?<first>\\d+),\\s*(?<second>\\d+)\\)"); Match matcher1 = pattern1.Match(expression); Match matcher2 = pattern2.Match(expression); if (matcher1.Success) { string otherElementStr = matcher1.Groups["word"].Value; var otherElement = Utils.SearchIElement(otherElementStr, scriptGenerationParams.ListUIElements); re += GetScriptAccessElement(otherElement, scriptGenerationParams.InstanceName); } else if (matcher2.Success) { string arg1Str = matcher2.Groups["first"].Value; string arg2Str = matcher2.Groups["second"].Value; re += Int32.Parse(arg1Str) + ";" + Int32.Parse(arg2Str); } else { LogError(logger, "problem with expression: " + expression); return(null); } re += ");"; re += NEW_LINE; re += "Mouse.ButtonUp(System.Windows.Forms.MouseButtons.Left);"; return(new ScriptsExpression(re)); }
public override ScriptsExpression GenRawRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { string re = ""; if (!Regex.IsMatch(expression, SINGLE_QUOTE)) { return(null); } string value = RemoveSingleQuote(expression); value = replaceReturnChar(value); string node_name = getScriptAccessRanorexElement(scriptGenerationParams.SpecNode, scriptGenerationParams.InstanceName); /** * modified by duongtd on 12/10/17, consider to revert if necessary */ // re += ".PressKeys(\"" + value + "\");"; if (scriptGenerationParams.SpecNode.UIElement is ComboBoxElement) { re += (node_name + ".SelectedItemText = \"" + value + "\";"); } /** * repo.MainForm.DataGridView11.DataGridView1.Rows[1].Cells[0] */ else if (Regex.IsMatch(node_name, "(?s).*\\.Rows\\[\\d+\\].*")) { re += node_name + ".DoubleClick();" + NEW_LINE; re += node_name + ".PressKeys(\"" + value + "\");" + NEW_LINE; re += node_name + ".PressKeys(\"{RETURN}\");"; } else { re += (node_name + ".TextValue = \"" + value + "\";"); } return(new ScriptsExpression(re)); }
public override ScriptsExpression GenRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { return(HandleAndGenScripts(scriptGenerationParams, ScriptType.Ranorex)); }
//scripts without comment or try/catch public abstract ScriptsExpression GenRawRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams);
public override ScriptsExpression GenRawRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { Regex pattern1 = new Regex("RightClick\\s+'[\\w|\\s]+'\\s*(->\\s*'[\\w|\\s]+'\\s*)*"); Match matcher1 = pattern1.Match(expression); Regex pattern4 = new Regex("RightClick(\\s*\\[(\\d+?);\\s*(\\d+?)\\]){0,1}"); Match matcher4 = pattern4.Match(expression); string re = ""; if (matcher1.Success) { string[] elements = Regex.Split(expression.Substring(RIGHT_CLICK.Length).Trim(), "->"); /** * modified by duongtd on 12/10/17, consider to revert if necessary */ for (int fi = 0; fi < elements.Length; fi++) { string element = elements[fi]; element = element.Trim(); if (!Regex.IsMatch(element, SINGLE_QUOTE)) { LogError(logger); re = MISSING_STATEMENT; break; } element = RemoveSingleQuote(element); if (re != null && !re.Equals("")) { re += NEW_LINE; } IElement otherNode = Utils.SearchIElement(element, scriptGenerationParams.ListUIElements); //if not found if (otherNode == null) { LogError(logger, "Can not find element: " + element); return(null); } if (re != null && !re.Equals("")) { re += getElementExp(otherNode) + ".RightClick();"; } } //return re; } else if (matcher4.Success) { re += getElementExp1(scriptGenerationParams.SpecNode.UIElement, getScriptAccessRanorexElement(scriptGenerationParams.SpecNode, scriptGenerationParams.InstanceName)) + "."; re += "RightClick("; if (matcher4.Groups[1] != null && !matcher4.Groups[1].Value.Trim().Equals("")) { string arg1Str = matcher4.Groups[2].Value; string arg2Str = matcher4.Groups[3].Value; re += "\"" + Int32.Parse(arg1Str) + ";" + Int32.Parse(arg2Str) + "\""; } re += ");"; } else { LogError(logger, "problem with expression: " + expression); return(null); } return(new ScriptsExpression(re)); }
public override ScriptsExpression GenRawRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { throw new NotImplementedException(); }
public override ScriptsExpression GenRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { return(base.GenRanorexScripts(scriptGenerationParams)); }
public override ScriptsExpression GenRawRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { string re = "Delay.Milliseconds(" + NormalizeExpression1(expression) + "*Config.DURATION);"; return(new ScriptsExpression(re)); }
public override ScriptsExpression GenRawRanorexScripts(IRanorexScriptGenerationParams scriptGenerationParams) { return(GetRawRanorexScripts(scriptGenerationParams, this.expression)); }