示例#1
0
        void attributeForm_onAttributeSelected(string name, string value)
        {
            AgentResponse agentResponse = new AgentResponse();

            agentResponse.messageType = AgentResponse.MessageType.CAPTURE_STEP_REPONSE;

            RanorexStepCaptureReponse captureResponse = new RanorexStepCaptureReponse();

            agentResponse.stepCaptureReponse = captureResponse;
            captureResponse.action           = "Get Attribute";

            ElementInfo elementInfo = attributeForm.currentElement;

            captureResponse.target = elementInfo.Path.ToResolvedString();

            Dictionary <string, object> properties = new Dictionary <string, object>();

            properties.Add("name", name);

            captureResponse.properties = properties;

            RanorexStepExecutionResponse executionResponse = new RanorexStepExecutionResponse();

            executionResponse.success = true;
            executionResponse.message = value;

            agentResponse.stepExecutionResponse = executionResponse;

            agentServer.SendMessage(agentResponse);
        }
示例#2
0
        private void ProcessValidateItems(ElementInfo elementInfo, IList <ValidationRecordItem> recordedItems)
        {
            FlushRecording();

            AgentResponse agentResponse = new AgentResponse();

            agentResponse.messageType = AgentResponse.MessageType.CAPTURE_STEP_REPONSE;

            RanorexStepCaptureReponse    captureResponse   = new RanorexStepCaptureReponse();
            RanorexStepExecutionResponse executionResponse = new RanorexStepExecutionResponse();

            agentResponse.stepCaptureReponse = captureResponse;

            Dictionary <string, object> properties = new Dictionary <string, object>();

            Dictionary <string, string> attributes     = new Dictionary <string, string>();
            Dictionary <string, object> structuredData = new Dictionary <string, object>();

            foreach (ValidationRecordItem item in recordedItems)
            {
                if (item.Action == ValidationAction.NotExists || item.Action == ValidationAction.Exists)
                {
                    continue;
                }

                if (elementInfo == null)
                {
                    elementInfo = item.Info;
                }
                if (item.Action == ValidationAction.CompareImage || item.Action == ValidationAction.ContainsImage)
                {
                    ImageSearchProperties searchProps = item.ImageBasedLocation;
                    Rectangle             imgRect     = searchProps.ImageSelectionRectangle;
                    CompressedImage       image       = elementInfo.LiveElementOrSnapshot.CaptureCompressedImage();
                    properties.Add("image", image.ToBase64String());
                    properties.Add("imageAction", item.Action.ToString());
                    properties.Add("clipX", imgRect.X);
                    properties.Add("clipY", imgRect.Y);
                    properties.Add("clipWidth", imgRect.Width);
                    properties.Add("clipHeight", imgRect.Height);

                    structuredData.Add("imageValidated", true);
                }
                else
                {
                    executionResponse.message += item.MatchName + "=" + item.MatchValue + "\n";
                    attributes.Add(item.MatchName, item.MatchValue);
                }
            }

            properties.Add("attributes", attributes);
            structuredData.Add("attributes", attributes);
            captureResponse.action = "Get Attribute";

            string absolutePath = elementInfo.Path.ToResolvedString();

            if (absolutePath.StartsWith("/mobileapp"))
            {
                absolutePath = Regex.Replace(absolutePath, "/mobileapp\\[@devicename='[^\\/]*'\\]", "/mobileapp");
            }
            captureResponse.target = absolutePath;

            captureResponse.properties = properties;

            executionResponse.structuredData = structuredData;
            executionResponse.success        = true;

            agentResponse.stepExecutionResponse = executionResponse;


            agentServer.SendMessage(agentResponse);
        }
示例#3
0
        private void ProcessRecordItem(RecordItem recordItem)
        {
            if (recordingFlushed)
            {
                AgentResponse agentResponse = new AgentResponse();
                agentResponse.messageType = AgentResponse.MessageType.CAPTURE_STEP_REPONSE;

                RanorexStepCaptureReponse captureResponse = new RanorexStepCaptureReponse();
                agentResponse.stepCaptureReponse = captureResponse;

                Dictionary <string, object> properties = new Dictionary <string, object>();
                XmlNode parentNode = new XmlNode("recorditem");
                XmlNode recordNode = recordItem.CreateXmlNode(parentNode, false);

                properties.Add("attributes", recordNode.Attributes);

                captureResponse.action = recordItem.DisplayName;

                if (recordItem is ElementRecordItem)
                {
                    RepositoryEntry repoEntry = ((ElementRecordItem)recordItem).GetBoundRepositoryEntry();

                    if (repoEntry != null)
                    {
                        string absolutePath = repoEntry.AbsolutePath.ToResolvedString();
                        if (absolutePath.StartsWith("/mobileapp"))
                        {
                            absolutePath = Regex.Replace(absolutePath, "/mobileapp\\[@devicename='[^\\/]*'\\]", "/mobileapp");
                        }
                        captureResponse.target = absolutePath;
                    }
                }

                if (recordItem is MouseRecordItem)
                {
                    MouseRecordItem mouseItem = (MouseRecordItem)recordItem;
                    captureResponse.action = mouseItem.Action.ToString();
                    properties.Add("button", mouseItem.Button.ToString());
                    properties.Add("location", mouseItem.ElementLocation.FixedLocation.X + ";" + mouseItem.ElementLocation.FixedLocation.Y);
                    properties.Add("duration", 200);
                    captureResponse.properties = properties;
                    Console.WriteLine(mouseItem.Action.ToString());
                    Console.WriteLine((String)properties["location"]);
                    Console.WriteLine((String)captureResponse.target);
                    Debug.Print((String)mouseItem.Action.ToString());
                    Console.Write((String)mouseItem.Action.ToString());
                    agentServer.SendMessage(agentResponse);
                }
                else if (recordItem is KeyboardSequenceRecordItem)
                {
                    KeyboardSequenceRecordItem sequenceItem = (KeyboardSequenceRecordItem)recordItem;
                    properties.Add("sequence", sequenceItem.KeySequence);
                    properties.Add("pressTime", 0);
                    properties.Add("duration", 200);
                    captureResponse.properties = properties;
                    agentServer.SendMessage(agentResponse);
                }
                else if (recordItem is KeyboardRecordItem)
                {
                    KeyboardRecordItem keyboardItem = (KeyboardRecordItem)recordItem;
                    properties.Add("data", keyboardItem.KeyData.ToString());
                    properties.Add("scanCode", keyboardItem.ScanCode);
                    properties.Add("setModifiers", keyboardItem.SetModifiers);
                    properties.Add("pressTime", 0);
                    properties.Add("duration", 200);
                    captureResponse.properties = properties;
                    agentServer.SendMessage(agentResponse);
                }
                else if (recordItem is MouseWheelRecordItem)
                {
                    MouseWheelRecordItem wheelItem = (MouseWheelRecordItem)recordItem;
                    string orientation             = wheelItem.Orientation.ToString();
                    properties.Add("orientation", orientation);
                    properties.Add("delta", wheelItem.Delta);
                    properties.Add("duration", 200);
                    captureResponse.properties = properties;
                    agentServer.SendMessage(agentResponse);
                }
                else if (recordItem is SetValueRecordItem)
                {
                    SetValueRecordItem setValueItem = (SetValueRecordItem)recordItem;
                    properties.Add("name", setValueItem.AttributeName);
                    properties.Add("value", setValueItem.AttributeValue);
                    captureResponse.properties = properties;
                    agentServer.SendMessage(agentResponse);
                }
                else if (recordItem is ElementRecordItem)
                {
                    ElementRecordItem elementItem = (ElementRecordItem)recordItem;
                    captureResponse.properties = properties;
                    agentServer.SendMessage(agentResponse);
                }
            }
        }