示例#1
0
        public static IWebElement FindElement(WebItem webItem)
        {
            int timeoutInSeconds = 30;     // always use 30 second wait

            if (webItem.xPath != "")
            {
                var wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(timeoutInSeconds));

                try
                {
                    return(wait.Until <IWebElement>((d) =>
                    {
                        return d.FindElement(By.XPath(webItem.xPath));
                    }));
                }
                catch (WebDriverTimeoutException e)
                {
                    WriteLog.WriteLogToFile("Exception: WebDriverTimeoutException ", false);
                    return(null);
                }
            }
            return(null);
        }
示例#2
0
        public static IWebElement FindElement(WebItem webItem)
        {
            int timeoutInSeconds = 30; // always use 30 second wait

                if (webItem.xPath != "")
                {
                    var wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(timeoutInSeconds));

                    try
                    {
                        return wait.Until<IWebElement>((d) =>
                    {
                            return d.FindElement(By.XPath(webItem.xPath));

                    });
                    }
                    catch (WebDriverTimeoutException e)
                    {
                        WriteLog.WriteLogToFile("Exception: WebDriverTimeoutException ", false);
                        return null;
                    }
                }
                return null;
        }