Ejemplo n.º 1
0
        public bool waitForVisibilityOfElementUntillTimeout(By lookupBy, double timeout)
        {
            bool          bln  = false;
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeout));

            try
            {
                WebElement ele = wait.Until(ExpectedConditions.ElementIsVisible(lookupBy));//sunil
                bln = true;
            }
            catch (Exception ex)
            {
                System.Drawing.Imaging.ImageFormat format = System.Drawing.Imaging.ImageFormat.Jpeg;
                ((ITakesScreenshot)driver).GetScreenshot().SaveAsFile(Path.Combine(projectLoc, TestContext.CurrentContext.Test.Name + "-" + DateTime.Now.ToString("dd-M-yyyy", CultureInfo.InvariantCulture) + "." + format), ScreenshotImageFormat.Jpeg);
                Assert.Fail(lookupBy + " is not visible for " + timeout + " seconds." + " with message :" + ex.Message);
                throw new Exception(ex.Message);
            }

            return(bln);
        }
Ejemplo n.º 2
0
        internal WebElement waitForElementVisible(By lookupBy, int maxWaitTime = 60)
        {
            WebElement element = null;

            try
            {
                element = new WebDriverWait(driver, TimeSpan.FromSeconds(maxWaitTime)).Until(ExpectedConditions.ElementIsVisible(lookupBy));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            if (element != null)
            {
                try
                {
                    string             script     = String.Format(@"arguments[0].style.cssText = ""border-width: 4px; border-style: solid; border-color: {0}"";", "orange");
                    JavascriptExecutor jsExecutor = (JavascriptExecutor)driver;
                    //jsExecutor.ExecuteScript(script, new object[] { element });
                    //jsExecutor.ExecuteScript(String.Format(@"$(arguments[0].scrollIntoView(true));"), new object[] { element });
                }
                catch { }
            }
            return(element);
        }