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_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; }
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 UIATestObject_NoCachedProperties() { AppModel model = AppModelManager.Load("UnitTestObjectModel1.json", ModelLoadLevel.ReplayOnly); ITestObject testObject = model.FindFirst(o => o.NodeName == "CachedPropertyTestNode"); CachedPropertyGroup cachedObject = testObject.GetContext <CachedPropertyGroup>(); Assert.AreEqual(null, cachedObject); }
public void UIATestObject_CachedProperties() { AppModel model = AppModelManager.Load("UnitTestObjectModel1.json", ModelLoadLevel.Full); ITestObject testObject = model.FindFirst(o => o.NodeName == "CachedPropertyTestNode"); CachedPropertyGroup cachedObject = testObject.GetContext <CachedPropertyGroup>(); Assert.AreNotEqual(null, cachedObject); Assert.AreEqual("asdfasfdasdfasdf.png", cachedObject.Properties["imageFile"]); }
public void UIACondition_CachedProperties() { ObjectDescriptor descriptor = ObjectDescriptor.FromJson( @" { ntype: ""uia"", nname: ""button1"", identifyProperties:{""name"": ""1""}, cachedProperties:{""className"": ""QWidget""}, description: ""button"" }" ); UIATestObject testObject = UIATestObject.ToTestObject(descriptor); CachedPropertyGroup cachedGroup = testObject.GetContext <CachedPropertyGroup>(); Assert.AreNotEqual(null, cachedGroup); UIACondition condition = new UIACondition(testObject); Assert.AreEqual(1, condition.CachedProperties.Count); }
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); }
public void TestObjectNurse_ctor() { UIATestObject testObject = new UIATestObject(); testObject.NodeName = "MyTestObject"; testObject.ControlType = ControlType.CheckBox; TestObjectNurse nurseObject = new TestObjectNurse(testObject); Assert.AreEqual(testObject.NodeName, nurseObject.NodeName); Assert.AreEqual(testObject.ControlTypeString, nurseObject.ControlTypeString); string displayName = testObject.ControlTypeString + ": " + testObject.NodeName; Assert.AreEqual(displayName, nurseObject.TreeNode.Text); CachedPropertyGroup cachedGroup = new CachedPropertyGroup(); cachedGroup.Properties[UIAControlKeys.ImagePath] = "pathToImage.png"; testObject.SetContext <CachedPropertyGroup>(cachedGroup); TestObjectNurse nurseObject2 = new TestObjectNurse(testObject); Assert.AreEqual("pathToImage.png", nurseObject2.ImageFile); }
private void Init(ITestObject testObject) { _testObject = (UIATestObject)testObject; _cachedProperties = testObject.GetContext <CachedPropertyGroup>(); }