Пример #1
0
 protected BasePage(BrowserBase browser)
 {
     if (browser?.Driver != null)
     {
         PageFactory.InitElements(browser.Driver, this);
     }
     BrowserBase = browser;
 }
Пример #2
0
        /// <summary>
        /// Method to Create a Page Instance using Reflection
        /// </summary>
        /// <param name="pageName"></param>
        /// <param name="browserBase"></param>
        /// <returns></returns>
        /// <exception cref="InvalidOperationException"></exception>
        public static BasePage CreatePageInstance(string pageName, BrowserBase browserBase)
        {
            string trimmedPageName = pageName.Replace(" ", string.Empty).Trim();

            string assemblyName = Assembly.GetExecutingAssembly().FullName.Split(',')[0];
            string fullPageName = $"{assemblyName}.Pages.{trimmedPageName},{assemblyName}";

            GetCurrentInstance = Activator.CreateInstance(Type.GetType(fullPageName), browserBase) as BasePage;
            if (!GetCurrentInstance.GetType().IsSubclassOf(typeof(BasePage)))
            {
                throw new InvalidOperationException(
                          $"Exception Occured while create page instance for : {trimmedPageName}. Which is not a BasePage derived class");
            }
            return(GetCurrentInstance);
        }
        /// <summary>
        ///  Extenstion method to move the cursor to an element using Actions method
        /// </summary>
        /// <param name="element"></param>
        /// <param name="browserBase"></param>
        public static void MoveToElementByAction(this IWebElement element, BrowserBase browserBase)
        {
            var action = new Actions(browserBase.Driver);

            action.MoveToElement(element).Build().Perform();
        }
Пример #4
0
 public Hooks(BrowserBase browserBase, ScenarioContext scenarioContext, FeatureContext featureContext)
 {
     _featureContext  = featureContext;
     _scenarioContext = scenarioContext;
     _browserBase     = browserBase;
 }