Exemplo n.º 1
0
        public void InitPageObjects(Driver driver)
        {
            var pageObject = GetType().GetFields(FrameworkConstants.BindingFlags).Where(field => field.FieldType.IsSubclassOf(typeof(PageObject))).FirstOrDefault();

            if (GetType().GetFields(FrameworkConstants.BindingFlags).Where(field => field.FieldType.IsSubclassOf(typeof(PageObject))).Count() > 1)
            {
                throw new Exception("Steps must have only one PageObject");
            }
            pageObject.SetValue(this, Activator.CreateInstance(pageObject.FieldType));
            WorkPage = (PageObject)pageObject.GetValue(this);
            WorkPage.InitWebelements(driver);
        }