Exemple #1
0
        public LandingPage LoginAsAdmin(string username, string password)
        {
            // https://crm422752.crm.dynamics.com/
            WebDriver.ElementWithWait(x => x.FindElement(By.Id("i0116")), TimeSpan.FromSeconds(10)).Clear();
            WebDriver.ElementWithWait(x => x.FindElement(By.Id("i0116")), TimeSpan.FromSeconds(10)).SendKeys(username);
            WebDriver.ElementWithWait(x => x.FindElement(By.Id("i0116")), TimeSpan.FromSeconds(10)).SendKeys(Keys.Enter);

            // ugly
            Thread.Sleep(1000);

            WebDriver.FindElement(By.Id("i0118")).Clear();
            Thread.Sleep(500);
            WebDriver.ElementWithWait(x => x.FindElement(By.Id("i0118")), TimeSpan.FromSeconds(10))
            .SendKeys(password);

            Thread.Sleep(500);

            WebDriver.ElementWithWait(x => x.FindElement(By.Id("idSIButton9")), TimeSpan.FromSeconds(10))
            .Click();

            Thread.Sleep(3000);

            var staySignedInDialog = WebDriver.ElementWithWait(x => x.FindElement(By.Id("displayName")), TimeSpan.FromSeconds(10));

            if (staySignedInDialog?.Text == "*****@*****.**")
            {
                return(NavigateTo <LandingPage>(By.Id("idBtn_Back"), e => e.Click()));
            }

            return(null);
        }
Exemple #2
0
        ///// <summary>
        ///// JQuery selector example
        ///// </summary>
        //public IWebElement LoginButton => WebDriver.FindElementByJQuery("input[name='btnSubmit']");

        public LoginPage BrittleLoginAsAdmin(string baseUrl, string password)
        {
            // https://crm422752.crm.dynamics.com/
            WebDriver.Navigate().GoToUrl(baseUrl);

            UserIdField.Clear();
            // sending a single quote is not possible with the Chrome Driver, it sends two single quotes!
            UserIdField.SendKeys("*****@*****.**");

            NextButton.Click();

            PasswordField.Clear();
            PasswordField.SendKeys(password);

            var wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(5));

            wait.Until(f => f.FindElements(By.XPath("//div[@class='col-xs-24 no-padding-left-right button-container']/div/input")).FirstOrDefault());

            SignInButton = WebDriver.FindElements(By.Id("idSIButton9")).FirstOrDefault();
            SignInButton.Click();

            var staySignedInDialog = WebDriver.FindElement(By.XPath("//div[@role='heading']"));

            if (staySignedInDialog?.Text == "Stay signed in?")
            {
                wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(5));
                wait.Until(f => f.FindElements(By.XPath("//div[@class='col-xs-24 no-padding-left-right button-container']/div/input")).FirstOrDefault());

                var noButton = WebDriver.FindElements(By.Id("idBtn_Back")).FirstOrDefault();
                noButton.Click();
            }

            return(this);
        }
        private IEnumerable <String> GetColumnNames()
        {
            var selector = $"#{_gridId} thead th[{PropertyNameAttribute}]";

            return
                (Browser
                 .FindElements(By.jQuery(selector))
                 .Select(e => e.GetAttribute(PropertyNameAttribute)
                         .Split('_')
                         .Last())
                 .ToList());
        }
Exemple #4
0
 public static string GetText(this IWebDriver driver)
 {
     return(driver.FindElement(By.TagName("body")).Text);
 }
Exemple #5
0
 public static int CountNumberOfElements(this IWebDriver browser, By by, Func <IWebElement, Boolean> predicate = null)
 {
     return(browser.FindElements(by, predicate).Count());
 }
Exemple #6
0
 public static IEnumerable <IWebElement> FindElements(this IWebDriver driver, By by, Func <IWebElement, bool> predicate)
 {
     return(driver.FindElements(by).Where(predicate));
 }
Exemple #7
0
 public static IWebElement FindElement(this IWebDriver driver, By by, Func <IWebElement, bool> predicate)
 {
     return(driver.FindElements(by, predicate).First());
 }
 public static IEnumerable<IWebElement> WaitForElements(this IWebDriver driver, By.jQueryBy by,
                                                        Func<IWebElement, bool> predicate = null,
                                                        int seconds = DefaultSecondTimeout)
 {
     return driver.WaitForElements(d => d.FindElements(by), predicate, seconds);
 }
 public static IWebElement WaitForElement(this IWebDriver driver, By.jQueryBy by,
                                          Func<IWebElement, bool> predicate = null,
                                          int seconds = DefaultSecondTimeout)
 {
     return driver.WaitForElements(by, predicate, seconds).First();
 }
 public static int CountNumberOfElements(this IWebDriver browser, By by, Func<IWebElement, Boolean> predicate = null)
 {
     return browser.FindElements(by, predicate).Count();
 }
 public static IEnumerable<IWebElement> FindElements(this IWebDriver driver, By by, Func<IWebElement, bool> predicate)
 {
     return driver.FindElements(by).Where(predicate);
 }
 public static IWebElement FindElement(this IWebDriver driver, By by, Func<IWebElement, bool> predicate)
 {
     return driver.FindElements(by, predicate).First();
 }
 public static bool HasElement(this IWebDriver driver, By.jQueryBy byJQuery)
 {
     return driver.HasElement(d => d.FindElement(byJQuery));
 }
Exemple #14
0
        private IWebElement GetCellFor(int rowIndex, PropertyInfo property)
        {
            var selector = GetCellSelector(rowIndex, property.Name);

            return(Browser.FindElementByjQuery(By.jQuery(selector)));
        }