public SETestObject(ObjectDescriptor descriptor) { _nodeName = descriptor.Name; _description = descriptor.Description; IdentifyPropertyGroup propertyItem = descriptor.GetItem <IdentifyPropertyGroup>(); CachedPropertyGroup cachedItem = descriptor.GetItem <CachedPropertyGroup>(); if (cachedItem != null) { SetContext <CachedPropertyGroup>(cachedItem); } _properties = (propertyItem != null) ? propertyItem.Properties : new PropertiesDictionary(); if (_properties.ContainsKey(WebControlKeys.Type)) { _type = _properties[WebControlKeys.Type]; } if (_children == null) { _children = new SETestObjectList(); } }
public void ObjectDescriptor_GetObjectData() { FormatterConverter formatConverter = new FormatterConverter(); SerializationInfo serializationInfo = new SerializationInfo(typeof(ObjectDescriptor), formatConverter); VirtualTestObject virtualTestObject = new VirtualTestObject() { BoundingRect = new Rect(10, 20, 30, 40) }; ObjectDescriptor descriptor = virtualTestObject.GetDescriptor(); StreamingContext context = new StreamingContext(); IdentifyPropertyGroup group = descriptor.GetItem <IdentifyPropertyGroup>(); Assert.AreEqual("10,20,30,40", group.Properties[UIAControlKeys.BoundingRectangle]); descriptor.GetObjectData(serializationInfo, context); string typeString = null; foreach (SerializationEntry entry in serializationInfo) { if (entry.Name == DescriptorKeys.NodeType) { typeString = (string)entry.Value; break; } else if (entry.Name == IdentifyPropertyGroup.Key) { group = (IdentifyPropertyGroup)entry.Value; break; } } Assert.AreEqual(NodeType.VirtualControl, typeString); Assert.AreEqual("10,20,30,40", group.Properties[UIAControlKeys.BoundingRectangle]); }
public override ObjectDescriptor GetDescriptor() { ObjectDescriptor descriptor = new ObjectDescriptor(); descriptor.Type = NodeType.Selenium; descriptor.Name = this.NodeName; descriptor.Description = this.Description; IdentifyPropertyGroup item = new IdentifyPropertyGroup(); item.Properties = _properties; item.Properties[WebControlKeys.Type] = _type; descriptor.SetItem <IdentifyPropertyGroup>(item); CachedPropertyGroup cachedGroup = GetContext <CachedPropertyGroup>(); if (cachedGroup != null) { descriptor.SetItem <CachedPropertyGroup>(cachedGroup); } foreach (ITestObject to in Children) { ObjectDescriptor childDescriptor = to.GetDescriptor(); descriptor.Children.Add(childDescriptor); childDescriptor.Parent = descriptor; } return(descriptor); }
public void ObjectDescriptor_PropertyGroup() { ObjectDescriptor descriptor = new ObjectDescriptor(); descriptor.Properties.Add("property1", "value1"); IdentifyPropertyGroup identifyGroup = new IdentifyPropertyGroup(); identifyGroup.Properties.Add("property3", "value3"); identifyGroup.Properties.Add("property4", "value4"); descriptor.SetItem <IdentifyPropertyGroup>(identifyGroup); CachedPropertyGroup cachedGroup = new CachedPropertyGroup(); cachedGroup.Properties.Add("property5", "value5"); cachedGroup.Properties.Add("property6", "value6"); cachedGroup.Properties.Add("imageFile", "testImageFile.png"); descriptor.SetItem <CachedPropertyGroup>(cachedGroup); string serializedObject = JsonUtil.SerializeObject(descriptor); Debug.WriteLine(serializedObject); Assert.IsTrue(serializedObject.IndexOf("property6") > 0); Assert.IsTrue(serializedObject.IndexOf("value6") > 0); Assert.IsTrue(serializedObject.IndexOf("testImageFile.png") > 0); Assert.IsTrue(serializedObject.IndexOf("imageFile") > 0); //TODO check the serialized JSON content; }
internal static VirtualTestObject CreateTestObject(ObjectDescriptor descriptor, ModelLoadLevel loadLevel) { IdentifyPropertyGroup propertyItem = descriptor.GetItem <IdentifyPropertyGroup>(); string boundingRect = propertyItem.Properties[UIAControlKeys.BoundingRectangle]; Rect rect = StringRectToRect(boundingRect); VirtualTestObject testObject = new VirtualTestObject(descriptor.Name, rect); return(testObject); }
public override ObjectDescriptor GetDescriptor() { ObjectDescriptor descriptor = base.GetDescriptor(); descriptor.Type = NodeType.VirtualControl; IdentifyPropertyGroup item = new IdentifyPropertyGroup(); item.Properties = new Dictionary <string, string>(); item.Properties[UIAControlKeys.BoundingRectangle] = RectToString(_rect); descriptor.SetItem(item); return(descriptor); }
public UIATestObject(ObjectDescriptor descriptor) { _nodeName = descriptor.Name; _description = descriptor.Description; _relation = descriptor.GetItem <VisualRelationPropertyItem>(); IdentifyPropertyGroup propertyItem = descriptor.GetItem <IdentifyPropertyGroup>(); CachedPropertyGroup cachedItem = descriptor.GetItem <CachedPropertyGroup>(); if (cachedItem != null) { SetContext <CachedPropertyGroup>(cachedItem); } _properties = (propertyItem != null) ? propertyItem.Properties : new PropertiesDictionary(); if (_properties.ContainsKey(UIAControlKeys.Type)) { _type = _properties[UIAControlKeys.Type].ToControlType(); } if (_children == null) { _children = new TestObjectList(); } /* * if (descriptor.Children != null) * { * foreach (ObjectDescriptor child in descriptor.Children) * { * new UIATestObject(child, this); * } * }*/ }
public override ObjectDescriptor GetDescriptor() { ObjectDescriptor descriptor = new ObjectDescriptor(); descriptor.Type = NodeType.UIAControl; descriptor.Name = this.NodeName; descriptor.Description = this.Description; if (_relation != null) { descriptor.SetItem <VisualRelationPropertyItem>(_relation); } IdentifyPropertyGroup item = new IdentifyPropertyGroup(); item.Properties = _properties; item.Properties[ControlKeys.Type] = _type.ControlTypeToString(); descriptor.SetItem <IdentifyPropertyGroup>(item); CachedPropertyGroup cachedGroup = GetContext <CachedPropertyGroup>(); if (cachedGroup != null) { descriptor.SetItem <CachedPropertyGroup>(cachedGroup); } foreach (ITestObject to in Children) { ObjectDescriptor childDescriptor = to.GetDescriptor(); descriptor.Children.Add(childDescriptor); childDescriptor.Parent = descriptor; } return(descriptor); }