public static Step ConvertFromPageObject(this Step step, SiteMap.Models.SiteMap sitemap) { foreach (var property in step.GetType().GetProperties()) { if (property.PropertyType == typeof(string)) { string value = property.GetValue(step, null)?.ToString(); if (value != null && value.StartsWith("#")) { string[] pathElements = value.Substring(1).Split('.'); var pageKey = pathElements[0]; string propertyPath = value.Substring(1 + 1 + pageKey.Length); var page = sitemap.GetPage(pageKey); var pageProperties = page.GetType().GetProperties(); var stepProperties = step.GetType().GetProperties(); var currentProperty = stepProperties.FirstOrDefault(p => p.Name == propertyPath); var selectorValue = ExpandoHelper.GetDynamicMember(page, propertyPath); if (selectorValue is string) { step.Param = (string)selectorValue; } if (selectorValue is Selector) { step.Selector = (Selector)selectorValue; } } } } return(step); }
public static Step ConvertFromPageObject(this Step step, ExecutionEnvironment executionEnvironment) { foreach (var property in step.GetType().GetProperties()) { if (property.PropertyType == typeof(string)) { string value = property.GetValue(step, null)?.ToString(); if (value != null && value.StartsWith("#") && value.Contains(".")) { string[] pathElements = value.Substring(1).Split('.'); var pageKey = pathElements[0]; string propertyPath = value.Substring(1 + 1 + pageKey.Length); var page = SiteMap.Instance.GetPage(pageKey, executionEnvironment); var selectorValue = ExpandoHelper.GetDynamicMember(page, propertyPath); if (selectorValue is string) { step.Param = (string)selectorValue; } if (selectorValue is Selector) { step.Selector = (Selector)selectorValue; } _log_.Trace($"Convert FromPage Object {value} / {step.Param} / {step.Selector}"); } } } return(step); }
public static void ApplyScenarioContext(this Step step, Context context) { var value = step.Value; if (value != null && value.StartsWith("$")) { string propertyPath = value.Substring(1); var contextValue = (string)ExpandoHelper.GetDynamicMember(context, propertyPath); step.Value = contextValue; } }
public static void ApplyScenarioContext(this Step step, Context context) { var value = step.Value; if (value != null && value.StartsWith("$")) { string propertyPath = value.Substring(1); var contextValue = (string)ExpandoHelper.GetDynamicMember(context, propertyPath); step.Value = contextValue; _log_.Trace($"Replacing Scenario Context {step.Name} / {step.Value} / {contextValue}"); } var param = step.Param; if (param != null && param.StartsWith("$")) { string propertyPath = param.Substring(1); var contextValue = (string)ExpandoHelper.GetDynamicMember(context, propertyPath); step.Param = contextValue; _log_.Trace($"Replacing Scenario Context {step.Name} / {step.Param} / {contextValue}"); } }