public static object CreateFieldValue(FieldInfo fieldInfo, ValueConstructionInfo info) { var criteria = fieldInfo.FindAttr <FindByAttribute>().SafeGet(a => a.GetCriteria()); var refinedInfo = info.RefineWith(criteria); return(CreateValue(refinedInfo)); }
public void InjectBrowser() { var fieldInfo = typeof(Sample).GetField("Browser"); var info = new ValueConstructionInfo(fieldInfo.FieldType, new[] { pageObjectElement }, browser); var value = WebElementGetExtensions.CreateFieldValue(fieldInfo, info); Assert.AreEqual(browser, value); }
public void InjectPageObject() { var fieldInfo = typeof(Sample).GetField("Control"); var info = new ValueConstructionInfo(fieldInfo.FieldType, new[] { pageObjectElement }, browser); var value = (PageObject)WebElementGetExtensions.CreateFieldValue(fieldInfo, info); Assert.AreEqual(browser, value.Browser); Assert.AreEqual(controlElement, value.Element); }
private static object GetLazyFieldValue(ValueConstructionInfo info) { return(LazyUtils.MakeLazy( info.ValueType, () => CreateValue( new ValueConstructionInfo( info.ValueType.GetGenericArguments().Single(), info.Elements, info.Browser)))); }
public static object CreateValue(ValueConstructionInfo info) { var factory = factories.FirstOrDefault(f => f.CanCreate(info.ValueType)); if (factory == null) { throw new WebDriverException(string.Format("Unsupported type {0}", info.ValueType)); } try { return(factory.Create(info)); } catch (WebDriverException e) { throw new WebDriverException("Can't create " + info.ValueType.Name + ". " + e.Message, e); } }
private static object CreateArray(ValueConstructionInfo info) { return(All(info.Elements, info.ValueType, info.Browser).ToArray(info.ValueType)); }
private static object GetPageObjectArrayFieldValue(ValueConstructionInfo info) { var elementType = info.ValueType.GetElementType(); return(CreateArray(new ValueConstructionInfo(elementType, info.Elements, info.Browser))); }
private static object GetPageObjectFieldValue(ValueConstructionInfo info) { return(Get(info.Elements, info.ValueType, info.Browser)); }