/// <summary>
        /// Returns <see cref="IWebElement"/> matching the <see cref="elementName"/>/>
        /// </summary>
        /// <param name="elementName">Name of the element defined in the definition file</param>
        /// <param name="webDriver">Instance of the <see cref="IWebDriver"/> to find element</param>
        /// <returns></returns>
        public IWebElement GetElement(string elementName, IWebDriver webDriver = null, string elementValue = "")
        {
            PageElementModel model = PageElements.Find(item => item.Name == elementName);

            if (model == null)
            {
                throw new ElementNotFoundException(elementName);
            }

            string definition = model.Definition;

            if (!string.IsNullOrEmpty(elementValue))
            {
                definition = this.ReplaceTokenInElementDefinition(model.Definition, elementValue);
            }

            Type type = typeof(By);

            MethodInfo methodInfo = type.GetMethod(model.How);

            if (webDriver != null)
            {
                return(webDriver.FindElement((By)methodInfo.Invoke(null, new object[] { definition })));
            }

            return(this.driver.FindElement((By)methodInfo.Invoke(null, new object[] { definition })));
        }
        /// <summary>
        /// Method to get definition of the element
        /// </summary>
        /// <param name="elementName"></param>
        /// <returns></returns>
        public string GetDefinition(string elementName)
        {
            PageElementModel model = PageElements.Find(item => item.Name == elementName);

            if (model == null)
            {
                throw new ElementNotFoundException(elementName);
            }

            return(model.Definition);
        }
        /// <summary>
        /// Method to get <see cref="By"/> locator of the element
        /// </summary>
        /// <param name="elementName">Name of the element</param>
        /// <returns><see cref="By"/> locator to find this element</returns>
        public By GetByLocator(string elementName, string elementValue = "")
        {
            PageElementModel model = this.PageElements.Find(item => item.Name == elementName);

            if (model == null)
            {
                throw new ElementNotFoundException(elementName);
            }

            string definition = model.Definition;

            if (!string.IsNullOrEmpty(elementValue))
            {
                definition = this.ReplaceTokenInElementDefinition(model.Definition, elementValue);
            }
            Type       type       = typeof(By);
            MethodInfo methodInfo = type.GetMethod(model.How);

            return((By)methodInfo.Invoke(null, new object[] { definition }));
        }
        private void ResolveElementsFromFile()
        {
            for (int i = 0; i < this.PageElements.Count; i++)
            {
                PageElementModel model = this.PageElements[i];

                if (model.How == "file")
                {
                    string filePath = string.Empty;

                    if (string.IsNullOrEmpty(this.basePath))
                    {
                        filePath = model.Definition;
                    }
                    else
                    {
                        filePath = System.IO.Path.Combine(this.basePath, model.Definition);
                    }
                    List <PageElementModel> models = JsonConvert.DeserializeObject <List <PageElementModel> >(File.ReadAllText(filePath));
                    this.PageElements[i] = models.Find(item => item.Name == model.Name);
                }
            }
        }