public void DisplayProductsAndRates()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl(HomeUrl);
                DemoHelper.Pause();

                ReadOnlyCollection <IWebElement> tableCells =
                    driver.FindElements(By.TagName("td"));

                Assert.Equal("Easy Credit Card", tableCells[0].Text);
                Assert.Equal("20% APR", tableCells[1].Text);

                Assert.Equal("Silver Credit Card", tableCells[2].Text);
                Assert.Equal("18% APR", tableCells[3].Text);

                Assert.Equal("Gold Credit Card", tableCells[4].Text);
                Assert.Equal("17% APR", tableCells[5].Text);
            }
        }
        public void BeInitiatedFromHomePage_EasyApplication_Prebuilt_Conditions()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl(HomeUrl);
                driver.Manage().Window.Minimize();
                DemoHelper.Pause();

                WebDriverWait wait =
                    new WebDriverWait(driver, TimeSpan.FromSeconds(11));
                IWebElement applyLink =
                    wait.Until(ExpectedConditions.ElementToBeClickable(By.LinkText("Easy: Apply Now!")));
                applyLink.Click();

                DemoHelper.Pause();

                Assert.Equal("Credit Card Application - Credit Cards", driver.Title);
                Assert.Equal(ApplyUrl, driver.Url);
            }
        }
Ejemplo n.º 3
0
        public void ClickOverlayedLink()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl("http://localhost:44108/jsoverlay.html");

                DemoHelper.Pause();

                string script = "document.getElementById('HiddenLink').click();";

                IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
                js.ExecuteScript(script);

                //driver.FindElement(By.Id("HiddenLink")).Click();

                DemoHelper.Pause();

                Assert.Equal("https://www.pluralsight.com/", driver.Url);
            }
        }
        public void CssSelectorCitrus()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl("https://www.citrus.ua/");

                driver.FindElement(
                    By.CssSelector("div.auth a.link-to")).Click();
                DemoHelper.Pause();

                //WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
                //IAlert alert = wait.Until(ExpectedConditions.AlertIsPresent());

                //DemoHelper.Pause();
                //IAlert alert = driver.SwitchTo().Alert();

                //Assert.Equal("Рад видеть Вас на моем сайте! Пошли дальше?", alert.Text);
                //alert.Accept();
            }
        }
        public void ReloadHomePageOnForward()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl(JobsUrl);
                DemoHelper.Pause();

                driver.Navigate().GoToUrl(HomeUrl);
                DemoHelper.Pause();

                driver.Navigate().Back();
                DemoHelper.Pause();

                driver.Navigate().Forward();
                DemoHelper.Pause();

                Assert.Equal(HomeTitle, driver.Title);
                Assert.Equal(HomeUrl, driver.Url);
            }
        }
        public void AlertIfLiveChatClosed()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl(HomeUrl);

                driver.FindElement(By.Id("LiveChat")).Click();

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

                IAlert alert = wait.Until(ExpectedConditions.AlertIsPresent());

                Assert.Equal("Live chat is currently closed.", alert.Text);

                DemoHelper.Pause();

                alert.Accept();

                DemoHelper.Pause();
            }
        }
        public void OpenContactFooterLinkInNewTab()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl(HomeUrl);

                driver.FindElement(By.Id("ContactFooter")).Click();

                DemoHelper.Pause();

                ReadOnlyCollection <string> allTabs = driver.WindowHandles;
                string homePageTab = allTabs[0];
                string contactTab  = allTabs[1];

                driver.SwitchTo().Window(contactTab);

                DemoHelper.Pause();

                Assert.EndsWith("/Home/Contact", driver.Url);
            }
        }
Ejemplo n.º 8
0
        public void ReloadHomePageOnBack()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl(homeUrl);
                IWebElement generationTokenElement =
                    driver.FindElement(By.Id("GenerationToken"));
                string initialToken = generationTokenElement.Text;
                DemoHelper.Pause();
                driver.Navigate().GoToUrl(AboutUrl);
                DemoHelper.Pause();
                driver.Navigate().Back();
                DemoHelper.Pause();

                Assert.Equal(homeTitle, driver.Title);
                Assert.Equal(homeUrl, driver.Url);
                //TODO: assert that page was reloaded
                string reloadedToken = driver.FindElement(By.Id("GenerationToken")).Text;
                Assert.NotEqual(initialToken, reloadedToken);
            }
        }
        public void BeInitiatedFromHomePage_EasyApplication()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl(HomeUrl);
                DemoHelper.Pause();

                IWebElement carouselNext =
                    driver.FindElement(By.CssSelector("[data-slide='next']"));
                carouselNext.Click();
                DemoHelper.Pause(1000);// allow carousel time to scroll

                IWebElement applyLink = driver.FindElement(By.LinkText("Easy: Apply Now!"));
                applyLink.Click();

                DemoHelper.Pause();

                Assert.Equal("Credit Card Application - Credit Cards", driver.Title);
                Assert.Equal(ApplyUrl, driver.Url);
            }
        }
Ejemplo n.º 10
0
        public void BeInitiatedFromHomePage_EasyApplication()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl(HomeUrl);
                DemoHelper.Pause();

                IWebElement carouselNext =
                    driver.FindElement(By.CssSelector("[data-slide='next']"));
                carouselNext.Click();

                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(1));

                IWebElement applyLink = wait.Until((d) => d.FindElement(By.LinkText("Easy: Apply Now!")));
                applyLink.Click();

                DemoHelper.Pause();

                Assert.Equal("Credit Card Application - Credit Cards", driver.Title);
                Assert.Equal(ApplyUrl, driver.Url);
            }
        }
Ejemplo n.º 11
0
        public void BeInitiatedFromHomePage_EasyApplication_Prebuilt_Conditions()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl(HomeUrl);
                DemoHelper.Pause();

                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(11));

                var element = By.LinkText("Easy: Apply Now!");

                //waits until the 'element' is clicked. if not, there will be timeout.
                IWebElement applyLink = wait.Until(
                    ExpectedConditions.ElementToBeClickable(element)
                    );
                applyLink.Click();

                DemoHelper.Pause();
                Assert.Equal("Credit Card Application - Credit Cards", driver.Title);
                Assert.Equal(ApplyUrl, driver.Url);
            }
        }
        public void ReloadHomePageOnForward()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl(AboutUrl);
                DemoHelper.Pause();

                driver.Navigate().GoToUrl(HomeUrl);
                DemoHelper.Pause();

                driver.Navigate().Back();
                DemoHelper.Pause();

                driver.Navigate().Forward();
                DemoHelper.Pause();

                Assert.Equal(HomeTitle, driver.Title);
                Assert.Equal(HomeUrl, driver.Url);

                // TODO: assert that page was reloaded
            }
        }
 public void BrowserManipulation()
 {
     using (IWebDriver driver = new ChromeDriver("."))
     {
         driver.Navigate().GoToUrl(HomePageUrl);
         DemoHelper.Pause(3000);
         driver.Manage().Window.Maximize();
         DemoHelper.Pause(3000);
         driver.Manage().Window.Minimize();
         DemoHelper.Pause(3000);
         driver.Manage().Window.Size = new System.Drawing.Size(300, 400);
         DemoHelper.Pause(3000);
         driver.Manage().Window.Position = new System.Drawing.Point(1, 1);
         DemoHelper.Pause(3000);
         driver.Manage().Window.Position = new System.Drawing.Point(100, 100);
         DemoHelper.Pause(3000);
         driver.Manage().Window.Position = new System.Drawing.Point(200, 200);
         DemoHelper.Pause(3000);
         driver.Manage().Window.Maximize();
         DemoHelper.Pause(3000);
     }
 }
Ejemplo n.º 14
0
        public void ReloadHomePageThenForms()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl(homeUrl);
                // DemoHelper.Pause();

                driver.Navigate().GoToUrl(formsUrl);
                // DemoHelper.Pause();

                IWebElement element = driver.FindElement(By.XPath("//span [contains(text(),'Practice Form')]"));

                //if (element != null)
                //{
                //    string practiceUrl = "https://demoqa.com/automation-practice-form";

                //    driver.Navigate().GoToUrl(practiceUrl);
                //}

                //  IWebElement element = driver.FindElement(By.XPath("html/body/div[2]/div[1]/img"));

                // IList<IWebElement> all = driver.FindElements(By.ClassName("menu-list"));
                // all[1].Click();

                //  all[1].Click();
                DemoHelper.Pause();
                //driver.Navigate().GoToUrl(formsUrl);
                //DemoHelper.Pause();

                //driver.Navigate().GoToUrl(practicalForm);
                //DemoHelper.Pause();

                //driver.Navigate().Forward();
                DemoHelper.Pause();

                Assert.Equal(pageTitle, pageTitle);
                Assert.Equal(homeUrl, driver.Url);
            }
        }
Ejemplo n.º 15
0
        public void BeInitiatedFromHomePage_CustomerSerivce()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl(homeUrlPluralsight);
                DemoHelper.Pause();

                IWebElement carouseNext = driver.FindElement(By.ClassName("show"));
                carouseNext.Click();
                DemoHelper.Pause(1000);
                //IWebElement carouseNexts = driver.FindElement(By.ClassName("show"));
                //if(carouseNexts.Text.Contains("Practice Form"))
                //{
                //    driver.Navigate().GoToUrl(practicalForm);
                //}

                IWebElement applyLink = driver.FindElement(By.LinkText("Easy: Apply Now!"));
                applyLink.Click();


                Assert.Equal(creditCardAppTitle, driver.Title);
            }
        }
        public void BeInitiatedFromHomePage_CustomerService()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                output.WriteLine($"{DateTime.Now.ToLongTimeString()} Navigating to '{HomeUrl}'");
                driver.Navigate().GoToUrl(HomeUrl);

                output.WriteLine($"{DateTime.Now.ToLongTimeString()} Finding element using explicit wait");
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(35));

                IWebElement applyLink =
                    wait.Until(ExpectedConditions.ElementToBeClickable(By.ClassName("customer-service-apply-now")));

                output.WriteLine($"{DateTime.Now.ToLongTimeString()} Found element Displayed={applyLink.Displayed} Enabled={applyLink.Enabled}");
                output.WriteLine($"{DateTime.Now.ToLongTimeString()} Clicking element");
                applyLink.Click();

                DemoHelper.Pause();

                Assert.Equal("Credit Card Application - Credit Cards", driver.Title);
                Assert.Equal(ApplyUrl, driver.Url);
            }
        }
        public void LoadApplicationPage()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl(HomeUrl);

                //var emailInput = driver.FindElement(By.Id("username"));

                //emailInput.SendKeys("test");

                //emailInput.Clear();

                //emailInput.Click();

                //Assert.True(emailInput.Displayed);


                DemoHelper.Pause();

                Assert.Equal(HomeTitle, driver.Title);
                Assert.Equal(HomeUrl, driver.Url);
            }
        }
Ejemplo n.º 18
0
        public void BeInitiatedFromHomePage_RandomGreeting_Using_XPath()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl(formsUrl);
                DemoHelper.Pause();

                //IWebElement randomGreetingLinkText =
                //    driver.FindElement(By.XPath("//*[@id='app']/div/div/div[2]/div[1]/div/div/div[2]/div"));

                IWebElement a = driver.FindElement(By.XPath("//div[@class='element-list collapse show']//*[name()='svg'][@stroke = 'currentColor']"));

                Actions builder = new Actions(driver);
                builder.Click(a).Build().Perform();


                string ur = driver.Url.Replace("/forms", "");
                driver.Navigate().GoToUrl(ur);


                // a.Click();

                //IList<IWebElement> all = driver.FindElements(By.TagName("svg"));
                // IList<IWebElement> all = driver.FindElements(By.ClassName("menu-list"))


                IWebElement randomGreetingLinkText =
                    driver.FindElement(By.XPath("//*[@id='item-0']/svg/path"));


                randomGreetingLinkText.Click();
                DemoHelper.Pause();

                Assert.Equal(creditCardAppTitle, driver.Title);
                Assert.Equal(creditCardApplyUrl, driver.Url);
            }
        }