public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); try { string command = (string)arguments["command"]; string mobileApp = (string)arguments["application"]; if (command == default(string)) { throw new Exception("No device selected!"); } if (mobileApp == default(string)) { throw new Exception("No application to run selected!"); } Host.Local.RunMobileApp(command, mobileApp); Delay.Milliseconds(400); stepResponse.success = true; } catch (Exception e) { stepResponse.message = "Ranorex Exception: " + e.Message; stepResponse.success = false; } return(stepResponse); }
public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); try { string orientation = (string)arguments.GetValueOrDefault <string, object>("orientation"); int delta = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("delta")); int delay = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("delay")); Report.Log(ReportLevel.Info, "Mouse", "Mouse Scroll " + orientation + " by " + delta + " units.", new RecordItemIndex(Agent.EXECUTION_INDEX)); if (orientation == "Vertical") { Mouse.ScrollWheel(delta); } else if (orientation == "Horizontal") { Mouse.ScrollHorizontalWheel(delta); } else { throw new Exception("Invalid orientation!"); } stepResponse.success = true; } catch (Exception e) { stepResponse.message = "Ranorex Exception: " + e.Message; stepResponse.success = false; } return(stepResponse); }
public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); try { string command = (string)arguments["command"]; string args = (string)arguments["arguments"]; bool maximized = (bool)arguments["maximized"]; if (command == default(string)) { throw new Exception("No file name defined to run!"); } Host.Local.RunApplication(command, args, "", maximized); Delay.Milliseconds(400); stepResponse.success = true; } catch (Exception e) { stepResponse.message = "Ranorex Exception: " + e.Message; stepResponse.success = false; } return(stepResponse); }
public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); try { string command = (string)arguments["command"]; string application = (string)arguments["application"]; if (command == default(string)) { throw new Exception("No device selected!"); } if (application == default(string)) { throw new Exception("No application to deploy!"); } Host.Local.InstrumentAndDeployAndroidApp(command, application, true, Host.DeploymentModes.Auto, 600000, new Ranorex.Core.Remoting.RecordItems.InstrumentApkOptions() { EnableWebTesting = true, TreeSimplification = true, FullImageComparison = false, RIdClass = "", KeyStore = "", KeyAlias = "", JdkBinPath = "", KeyStorePass = "", KeyPass = "" }); Delay.Milliseconds(400); stepResponse.success = true; } catch (Exception e) { MessageBox.Show(e.Message); stepResponse.message = "Ranorex Exception: " + e.Message; stepResponse.success = false; } return(stepResponse); }
public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); try { RepoItemInfo repoItemInfo = null; string target = (string)arguments.GetValueOrDefault <string, object>("target"); string action = (string)arguments.GetValueOrDefault <string, object>("action"); string startLocation = (string)arguments.GetValueOrDefault <string, object>("startlocation"); int distance = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("distance")); double direction = Convert.ToDouble(arguments.GetValueOrDefault <string, object>("direction")); int duration = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("duration")); int delay = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("delay")); int timeout = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("timeout")); bool retrieveImage = (bool)arguments.GetValueOrDefault <string, object>("retrieveImage"); if (timeout == default(int)) { timeout = 10000; } if (duration == default(int)) { duration = 0; } if (startLocation == default(string)) { startLocation = "0;0"; } if (target != default(string)) { repoItemInfo = CreateItemInfo(repo, target, timeout); Ranorex.Unknown adapter = CreateAdapter(repoItemInfo); Report.Log(ReportLevel.Info, "Touch Gestures", "Swipe gesture with direction '" + direction + "' starting from '" + startLocation + "' with distance '" + distance + "' with swipe duration '" + duration + "'", repoItemInfo, new RecordItemIndex(Agent.EXECUTION_INDEX)); adapter.Swipe(startLocation, direction, distance, duration, 0); if (retrieveImage) { stepResponse.image64 = GetImage64(adapter); } } else { } Delay.Milliseconds(200); stepResponse.success = true; } catch (Exception e) { stepResponse.message = "Ranorex Exception: " + e.Message; stepResponse.success = false; } return(stepResponse); }
public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); stepResponse.success = false; stepResponse.message = "Ranorex Exception: " + "Unknown action found! Cannot execute"; return(stepResponse); }
public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); try { RepoItemInfo repoItemInfo = null; string target = (string)arguments.GetValueOrDefault <string, object>("target"); string sequence = (string)arguments.GetValueOrDefault <string, object>("keySequence"); int duration = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("duration")); int delay = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("delay")); int timeout = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("timeout")); bool retrieveImage = (bool)arguments.GetValueOrDefault <string, object>("retrieveImage"); if (timeout == default(int)) { timeout = 10000; } if (duration == default(int)) { duration = 0; } if (target != default(string)) { repoItemInfo = CreateItemInfo(repo, target, timeout); Ranorex.Unknown adapter = CreateAdapter(repoItemInfo); Report.Log(ReportLevel.Info, "Keyboard", "Key '" + sequence + "' Press with focus on UI Element.", repoItemInfo, new RecordItemIndex(Agent.EXECUTION_INDEX)); adapter.PressKeys(sequence, duration); if (retrieveImage) { stepResponse.image64 = GetImage64(adapter); } } else { Report.Log(ReportLevel.Info, "Keyboard", "Key '" + sequence + "' Press.", new RecordItemIndex(Agent.EXECUTION_INDEX)); Keyboard.Press(sequence, duration); } Delay.Milliseconds(200); stepResponse.success = true; } catch (Exception e) { stepResponse.message = "Ranorex Exception: " + e.Message; stepResponse.success = false; } return(stepResponse); }
public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); try { RepoItemInfo repoItemInfo = null; string target = (string)arguments.GetValueOrDefault <string, object>("target"); string waitAction = (string)arguments.GetValueOrDefault <string, object>("waitAction"); int waitTimeout = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("waitTimeout")); int timeout = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("timeout")); if (waitAction == default(string)) { throw new Exception("No wait action defined!"); } if (target != default(string)) { repoItemInfo = CreateItemInfo(repo, target, timeout); } if (repoItemInfo != null) { switch (waitAction) { case "Exists": repoItemInfo.WaitForExists(waitTimeout); break; case "NotExists": repoItemInfo.WaitForNotExists(waitTimeout); break; } } else { throw new Exception("No target defined!"); } stepResponse.success = true; } catch (Exception e) { stepResponse.message = "Ranorex Exception: " + e.Message; stepResponse.success = false; } return(stepResponse); }
public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); try { RepoItemInfo repoItemInfo = null; Ranorex.Unknown adapter = null; string target = (string)arguments["target"]; string method = (string)arguments["method"]; int gracePeriod = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("gracePeriod")); int timeout = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("timeout")); if (timeout == default(int)) { timeout = 10000; } if (target != default(string)) { repoItemInfo = CreateItemInfo(repo, target, timeout); adapter = CreateAdapter(repoItemInfo); } else { throw new Exception("No target defined!"); } if (method == "CloseWindow") { Host.Local.CloseApplication(adapter, new Duration(gracePeriod)); } else if (method == "KillProcess") { Host.Local.KillApplication(adapter); } stepResponse.success = true; } catch (Exception e) { stepResponse.message = "Ranorex Exception: " + e.Message; stepResponse.success = false; } return(stepResponse); }
public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); try { RepoItemInfo repoItemInfo = null; Ranorex.Unknown adapter = null; string target = (string)arguments.GetValueOrDefault <string, object>("target"); string name = (string)arguments.GetValueOrDefault <string, object>("name"); string value = (string)arguments.GetValueOrDefault <string, object>("value"); int timeout = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("timeout")); bool retrieveImage = (bool)arguments.GetValueOrDefault <string, object>("retrieveImage"); if (timeout == default(int)) { timeout = 10000; } if (target != default(string)) { repoItemInfo = CreateItemInfo(repo, target, timeout); adapter = CreateAdapter(repoItemInfo); adapter.Element.SetAttributeValue(name, value); if (retrieveImage) { stepResponse.image64 = GetImage64(adapter); } stepResponse.message = ""; } else { throw new Exception("No target defined!"); } stepResponse.success = true; } catch (Exception e) { stepResponse.message = "Ranorex Exception: " + e.Message; stepResponse.success = false; } return(stepResponse); }
public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); try { string url = (string)arguments["command"]; string browser = (string)arguments["browserType"]; bool maximized = (bool)arguments["maximized"]; Host.Local.OpenBrowser(url, browser, "", false, maximized); Delay.Milliseconds(2000); stepResponse.success = true; } catch (Exception e) { stepResponse.message = "Ranorex Exception: " + e.Message; stepResponse.success = false; } return(stepResponse); }
public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); try { string command = (string)arguments["command"]; string application = (string)arguments["application"]; string applicationId = (string)arguments["applicationId"]; if (command == default(string)) { throw new Exception("No device selected!"); } if (application == default(string)) { throw new Exception("No application to deploy!"); } if (applicationId == default(string)) { throw new Exception("No application id defined!"); } Host.Local.DeployIosApp(command, application, applicationId); Delay.Milliseconds(400); stepResponse.success = true; } catch (Exception e) { MessageBox.Show(e.Message); stepResponse.message = "Ranorex Exception: " + e.Message; stepResponse.success = false; } return(stepResponse); }
public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); try { RepoItemInfo repoItemInfo = null; string target = (string)arguments.GetValueOrDefault <string, object>("target"); string action = (string)arguments.GetValueOrDefault <string, object>("itest-action"); string loc = (string)arguments.GetValueOrDefault <string, object>("elementlocation"); int duration = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("duration")); int delay = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("delay")); int timeout = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("timeout")); bool retrieveImage = (bool)arguments.GetValueOrDefault <string, object>("retrieveImage"); if (timeout == default(int)) { timeout = 10000; } if (duration == default(int)) { duration = 0; } if (loc == default(string)) { loc = "0;0"; } if (target != default(string)) { repoItemInfo = CreateItemInfo(repo, target, timeout); Ranorex.Unknown adapter = CreateAdapter(repoItemInfo); switch (action) { case "Touch": Report.Log(ReportLevel.Info, "Touch", "Touch item at " + loc + ".", repoItemInfo, new RecordItemIndex(Agent.EXECUTION_INDEX)); adapter.Touch(loc, duration); break; case "DoubleTap": Report.Log(ReportLevel.Info, "Touch", "DoubleTap item at " + loc + ".", repoItemInfo, new RecordItemIndex(Agent.EXECUTION_INDEX)); adapter.DoubleTap(loc); break; case "LongTouch": Report.Log(ReportLevel.Info, "Touch", "LongTouch item at " + loc + ".", repoItemInfo, new RecordItemIndex(Agent.EXECUTION_INDEX)); adapter.LongTouch(loc, duration); break; case "TouchStart": Report.Log(ReportLevel.Info, "Touch", "TouchStart item at " + loc + ".", repoItemInfo, new RecordItemIndex(Agent.EXECUTION_INDEX)); adapter.TouchStart(loc); break; case "TouchMove": Report.Log(ReportLevel.Info, "Touch", "TouchMove item at " + loc + ".", repoItemInfo, new RecordItemIndex(Agent.EXECUTION_INDEX)); adapter.TouchMove(loc, duration); break; case "TouchEnd": Report.Log(ReportLevel.Info, "Touch", "TouchEnd item at " + loc + ".", repoItemInfo, new RecordItemIndex(Agent.EXECUTION_INDEX)); adapter.TouchEnd(loc, duration); break; } if (retrieveImage) { stepResponse.image64 = GetImage64(adapter); } } else { } Delay.Milliseconds(200); stepResponse.success = true; } catch (Exception e) { stepResponse.message = "Ranorex Exception: " + e.Message; stepResponse.success = false; } return(stepResponse); }
public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); try { RepoItemInfo repoItemInfo = null; string target = (string)arguments.GetValueOrDefault <string, object>("target"); string action = (string)arguments.GetValueOrDefault <string, object>("itest-action"); string button = (string)arguments.GetValueOrDefault <string, object>("button"); string loc = (string)arguments.GetValueOrDefault <string, object>("location"); int duration = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("duration")); int delay = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("delay")); int timeout = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("timeout")); bool retrieveImage = (bool)arguments.GetValueOrDefault <string, object>("retrieveImage"); if (timeout == default(int)) { timeout = 10000; } if (duration == default(int)) { duration = 0; } if (button == default(string)) { button = "Unknown"; } if (loc == default(string)) { loc = "0;0"; } if (target != default(string)) { repoItemInfo = CreateItemInfo(repo, target, timeout); Ranorex.Unknown adapter = CreateAdapter(repoItemInfo); switch (action) { case "Click": Report.Log(ReportLevel.Info, "Mouse", "Mouse " + button + " Click item at " + loc + ".", repoItemInfo, new RecordItemIndex(Agent.EXECUTION_INDEX)); adapter.Click(GetButton(button), loc, duration); break; case "DoubleClick": Report.Log(ReportLevel.Info, "Mouse", "Mouse " + button + " Double Click item at " + loc + ".", repoItemInfo, new RecordItemIndex(Agent.EXECUTION_INDEX)); adapter.DoubleClick(GetButton(button), loc, duration); break; case "Move": Report.Log(ReportLevel.Info, "Mouse", "Mouse move to item at " + loc + ".", repoItemInfo, new RecordItemIndex(Agent.EXECUTION_INDEX)); adapter.MoveTo(loc, duration); break; case "Up": Report.Log(ReportLevel.Info, "Mouse", "Mouse " + button + " Up item at " + loc + ".", repoItemInfo, new RecordItemIndex(Agent.EXECUTION_INDEX)); adapter.MoveTo(loc, duration); Mouse.ButtonUp(GetButton(button)); break; case "Down": Report.Log(ReportLevel.Info, "Mouse", "Mouse " + button + " Down item at " + loc + ".", repoItemInfo, new RecordItemIndex(Agent.EXECUTION_INDEX)); adapter.MoveTo(loc, duration); Mouse.ButtonDown(GetButton(button)); break; } if (retrieveImage) { stepResponse.image64 = GetImage64(adapter); } } else { string[] locSplit = loc.Split(';'); switch (action) { case "Click": Report.Log(ReportLevel.Info, "Mouse", "Mouse " + button + " Click at {X=" + locSplit[0] + ",Y=" + locSplit[1] + "}.", new RecordItemIndex(Agent.EXECUTION_INDEX)); Mouse.MoveTo(Int32.Parse(locSplit[0]), Int32.Parse(locSplit[1]), duration); Mouse.Click(GetButton(button)); break; case "DoubleClick": Report.Log(ReportLevel.Info, "Mouse", "Mouse " + button + " Double Click at {X=" + locSplit[0] + ",Y=" + locSplit[1] + "}.", new RecordItemIndex(Agent.EXECUTION_INDEX)); Mouse.MoveTo(Int32.Parse(locSplit[0]), Int32.Parse(locSplit[1]), duration); Mouse.DoubleClick(GetButton(button)); break; case "Move": Report.Log(ReportLevel.Info, "Mouse", "Mouse Move at {X=" + locSplit[0] + ",Y=" + locSplit[1] + "}.", new RecordItemIndex(Agent.EXECUTION_INDEX)); Mouse.MoveTo(Int32.Parse(locSplit[0]), Int32.Parse(locSplit[1]), duration); break; case "Up": Report.Log(ReportLevel.Info, "Mouse", "Mouse Up at {X=" + locSplit[0] + ",Y=" + locSplit[1] + "}.", new RecordItemIndex(Agent.EXECUTION_INDEX)); Mouse.MoveTo(Int32.Parse(locSplit[0]), Int32.Parse(locSplit[1]), duration); Mouse.ButtonUp(GetButton(button)); break; case "Down": Report.Log(ReportLevel.Info, "Mouse", "Mouse Down at {X=" + locSplit[0] + ",Y=" + locSplit[1] + "}.", new RecordItemIndex(Agent.EXECUTION_INDEX)); Mouse.MoveTo(Int32.Parse(locSplit[0]), Int32.Parse(locSplit[1]), duration); Mouse.ButtonDown(GetButton(button)); break; } } Delay.Milliseconds(200); stepResponse.success = true; } catch (Exception e) { stepResponse.message = "Ranorex Exception: " + e.Message; stepResponse.success = false; } return(stepResponse); }
public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); try { RepoItemInfo repoItemInfo = null; string target = (string)arguments.GetValueOrDefault <string, object>("target"); string keyData = (string)arguments.GetValueOrDefault <string, object>("data"); int duration = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("duration")); int delay = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("delay")); int timeout = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("timeout")); int scanCode = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("scanCode")); int pressTime = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("pressTime")); bool retrieveImage = (bool)arguments.GetValueOrDefault <string, object>("retrieveImage"); bool setModifiers = (bool)arguments.GetValueOrDefault <string, object>("setModifiers"); string[] keys = keyData.Trim().Split(','); System.Windows.Forms.Keys key = (System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), keys[0]); for (int i = 1; i < keys.Length; i++) { key |= (System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), keys[i]); } if (timeout == default(int)) { timeout = 10000; } if (duration == default(int)) { duration = 0; } if (target != default(string)) { repoItemInfo = CreateItemInfo(repo, target, timeout); Ranorex.Unknown adapter = CreateAdapter(repoItemInfo); Report.Log(ReportLevel.Info, "Keyboard", "Key Press", new RecordItemIndex(Agent.EXECUTION_INDEX)); Keyboard.PrepareFocus(adapter); Keyboard.Press(key, scanCode, pressTime, 1, setModifiers); if (retrieveImage) { stepResponse.image64 = GetImage64(adapter); } } else { Report.Log(ReportLevel.Info, "Keyboard", "Key Press", new RecordItemIndex(Agent.EXECUTION_INDEX)); Keyboard.Press(key, scanCode, pressTime, 1, setModifiers); } Delay.Milliseconds(200); stepResponse.success = true; } catch (Exception e) { stepResponse.message = "Ranorex Exception: " + e.Message; stepResponse.success = false; } return(stepResponse); }
public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); try { RepoItemInfo repoItemInfo = null; Ranorex.Unknown adapter = null; string target = (string)arguments.GetValueOrDefault <string, object>("target"); string function = (string)arguments.GetValueOrDefault <string, object>("function"); string name = (string)arguments.GetValueOrDefault <string, object>("name"); string value = (string)arguments.GetValueOrDefault <string, object>("value"); if (function == default(string)) { throw new Exception("No validate function defined"); } if (target != default(string)) { repoItemInfo = new RepoItemInfo(repo, "CommandItem", target, 10000, null, "3529d992-a9f6-4df9-927a-3e7e1e08ca8b"); adapter = repoItemInfo.CreateAdapter <Ranorex.Unknown>(true); } if (adapter != null) { switch (function) { case "AttributeEqual": if (name == default(string)) { throw new Exception("No name to validate defined"); } if (value == default(string)) { throw new Exception("No value to validate defined"); } Validate.Attribute(adapter, name, value); break; case "Exists": Validate.Exists(adapter); break; case "NotExists": Validate.NotExists(adapter); break; case "AttributeRegEx": if (name == default(string)) { throw new Exception("No name to validate defined"); } if (value == default(string)) { throw new Exception("No value to validate defined"); } Validate.Attribute(adapter, name, new Regex(value)); break; case "AttributeContains": if (name == default(string)) { throw new Exception("No name to validate defined"); } if (value == default(string)) { throw new Exception("No value to validate defined"); } Validate.Attribute(adapter, name, new Regex(Regex.Escape(value))); break; case "AttributeNotContains": if (name == default(string)) { throw new Exception("No name to validate defined"); } if (value == default(string)) { throw new Exception("No value to validate defined"); } Validate.Attribute(adapter, name, new Regex("^((?!(" + Regex.Escape(value) + "))(.|\n))*$")); break; case "ContainsImage": break; case "CompareImage": break; } } else { } stepResponse.success = true; } catch (Exception e) { stepResponse.message = "Ranorex Exception: " + e.Message; stepResponse.success = false; } return(stepResponse); }
public override RanorexStepExecutionResponse Execute(Dictionary <string, object> arguments) { RanorexStepExecutionResponse stepResponse = new RanorexStepExecutionResponse(); try { RepoItemInfo repoItemInfo = null; Ranorex.Unknown adapter = null; string target = (string)arguments.GetValueOrDefault <string, object>("target"); int timeout = Convert.ToInt32(arguments.GetValueOrDefault <string, object>("timeout")); bool retrieveImage = (bool)arguments.GetValueOrDefault <string, object>("retrieveImage"); System.Collections.IDictionary imageProps = (System.Collections.IDictionary)arguments["imageValidationProperties"]; System.Collections.IList attributes = (System.Collections.IList)arguments["attributes"]; if (timeout == default(int)) { timeout = 10000; } if (target != default(string)) { repoItemInfo = CreateItemInfo(repo, target, timeout); adapter = CreateAdapter(repoItemInfo); Dictionary <string, object> structuredData = new Dictionary <string, object>(); Dictionary <string, object> receivedAttributes = new Dictionary <string, object>(); foreach (System.Collections.IDictionary attribute in attributes) { string name = (string)attribute["header"]; string value = adapter.Element.GetAttributeValueText(name); stepResponse.message += name + "=" + value + "\n"; receivedAttributes.Add(name, value); } structuredData.Add("attributes", receivedAttributes); if (imageProps != null) { string validationMode = (string)imageProps["validationMode"]; if (validationMode != "NONE") { string image = (string)imageProps["imageData"]; int rectX = Convert.ToInt32(imageProps["clipX"]); int rectY = Convert.ToInt32(imageProps["clipY"]); int rectWidth = Convert.ToInt32(imageProps["clipWidth"]); int rectHeight = Convert.ToInt32(imageProps["clipHeight"]); try { CompressedImage compressedImage = new CompressedImage(image); using (Bitmap bitmap = Imaging.Crop(compressedImage.Image, new Rectangle(rectX, rectY, rectWidth, rectHeight))) { compressedImage = new CompressedImage(bitmap); } if (validationMode == "CONTAINS_IMAGE") { Validate.ContainsImage(repoItemInfo, compressedImage, Imaging.FindOptions.Default); } else if (validationMode == "COMPARE_IMAGE") { Validate.ContainsImage(repoItemInfo, compressedImage, Imaging.FindOptions.Default); } structuredData.Add("imageValidated", "true"); stepResponse.message += "#imageValidated=true\n"; } catch (ValidationException e) { structuredData.Add("imageValidated", "false"); stepResponse.message += "#imageValidated=false\n"; } } } stepResponse.structuredData = structuredData; if (retrieveImage) { stepResponse.image64 = GetImage64(adapter); } } else { throw new Exception("No target defined!"); } stepResponse.success = true; } catch (Exception e) { stepResponse.message = "Ranorex Exception: " + e.Message; stepResponse.success = false; } return(stepResponse); }