Beispiel #1
0
        private void ParsePageConfig(PageObjectConfiguration pageObjectConfig)
        {
            PageObjectConfiguration basePage = GetBasePage(pageObjectConfig);

            if (basePage != null)
            {
                ParsePageConfig(basePage);
            }

            foreach (ElementConfiguration ec in pageObjectConfig.Elements)
            {
                string value  = ec.Value;
                FindBy findBy = ec.FindBy;

                if (ec.IsParameterized)
                {
                    Func <string, string[], IWebElement> parameterizedFinder = (str, args) => ParameterizedFindElementBy(value, findBy, args);
                    ec.ParameterizedFinder = parameterizedFinder;
                }
                else
                {
                    Func <string, IWebElement> finder = (str) => FindElementBy(value, findBy);
                    ec.Finder = finder;
                }

                _cachedQueries.Add(ec.Name, ec);
            }

            foreach (var kp in pageObjectConfig.Values)
            {
                pageObjectConfig.Type.GetProperty(kp.Key).SetValue(this, kp.Value, null);
            }
        }
Beispiel #2
0
        private PageObjectConfiguration GetBasePage(PageObjectConfiguration pageObjectConfig)
        {
            PageObjectConfiguration result = null;

            if (!string.IsNullOrEmpty(pageObjectConfig.BasePageName))
            {
                result = ApplicationObjectConfiguration.Instance.Pages.OfType <PageObjectConfiguration>().FirstOrDefault(p => p.Name == pageObjectConfig.BasePageName);
            }

            return(result);
        }
Beispiel #3
0
        // Gets the page from config file together with its properties
        private void GetPageFromConfig()
        {
            PageObjectConfiguration currentPage = ApplicationObjectConfiguration.Instance.Pages.OfType <PageObjectConfiguration>().FirstOrDefault(p => p.Type == this.GetType());

            if (currentPage != null)
            {
                if (currentPage.Individual)
                {
                    Url = TestConfiguration.GetPageUrl(string.IsNullOrEmpty(currentPage.UrlPageName)
                        ? currentPage.Name
                        : currentPage.UrlPageName) + (currentPage.Url != null ? currentPage.Url.OriginalString : "");
                }
                else
                {
                    Url = TestConfiguration.ApplicationUrl + (currentPage.Url != null ? currentPage.Url.OriginalString : "");
                }

                ParsePageConfig(currentPage);
            }
        }