Example #1
0
 public override void WaitUntilReady()
 {
     new WebDriverWait(Driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.UrlContains("instagram"));
     WaitUntilElementExists(By.XPath("//span[text()=' followers']")); // Followers label
 }
        public void WaitForUrlToConatin(String DesiredString)
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(40));

            wait.Until(ExpectedConditions.UrlContains(DesiredString));
        }
 public bool ValidarConteudoUrl(string conteudo)
 {
     return(Wait.Until(ExpectedConditions.UrlContains(conteudo)));
 }
Example #4
0
        public void TestAddNewComputer()
        {
            driver.Url = test_url;

            //Specify a wait object
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(15));

            //Click on Add a new computer
            IWebElement Add_Button = driver.FindElement(By.Id("add"));

            Add_Button.Click();

            //Wait for Page to Load
            var AddPage = wait.Until(ExpectedConditions.UrlContains("http://computer-database.herokuapp.com/computers/new"));

            Thread.Sleep(5000);
            //Enter a computer name
            IWebElement Computer_name = wait.Until(ExpectedConditions.ElementExists(By.XPath("//input[@id='name' and @type='text']")));

            Computer_name.SendKeys("Asus333");

            //Enter an introduced date
            IWebElement Introduced_date = wait.Until(ExpectedConditions.ElementExists(By.XPath("//input[@id='introduced' and @type='text']")));

            Introduced_date.SendKeys("1981-08-01");

            //Enter a discontinued date
            IWebElement Discontinued_date = wait.Until(ExpectedConditions.ElementExists(By.XPath("//input[@id='discontinued' and @type='text']")));

            Discontinued_date.SendKeys("1988-09-09");

            //Select  a company from the dropdown
            IWebElement company = wait.Until(ExpectedConditions.ElementExists(By.Id("company")));

            SelectElement selectcompany = new SelectElement(company);

            selectcompany.SelectByIndex(2);

            //Click on the Create button
            IWebElement Create_btn = driver.FindElement(By.XPath("//*[@id='main']/form/div/input"));

            Create_btn.Click();

            //Verify the message on successful creation

            var expected = "Done! Computer Asus333 has been created";
            var message  = driver.FindElement(By.XPath("//*[@id='main']/div[1]"));
            var actual   = message.Text;

            Assert.AreEqual(expected, actual);

            //Verify if the newly added computer is in the list by using Filter search box

            IWebElement Filter_textbox = wait.Until(ExpectedConditions.ElementExists(By.Id("searchbox")));

            Filter_textbox.SendKeys("Asus333");

            //Click Filter button
            IWebElement Filter_button = driver.FindElement(By.Id("searchsubmit"));

            Filter_button.Click();

            //Verify the new computer name is displayed
            IWebElement result = driver.FindElement(By.XPath("//*[@id='main']/table/tbody/tr/td[1]/a"));

            Assert.AreEqual(result.Text, "Asus333");
        }
        public bool Login(string username, string password)
        {
            bool flag = false;

            try
            {
                driver.Navigate().GoToUrl(SignInUrl);
                Thread.Sleep(1000);
                takescreenshot("login screen");
                //the driver can now provide you with what you need (it will execute the script)
                //get the source of the page
                //fully navigate the dom
                ShowDriverState();
                var pathElement = driver.FindElementById("UserName");
                pathElement.SendKeys(username);
                Thread.Sleep(500);
                var pass = driver.FindElementById("Password");
                pass.SendKeys(password);
                var signin = driver.FindElementByClassName("tyler-btn-primary");
                Thread.Sleep(500);
                signin.Submit();
                var body = new WebDriverWait(driver, TimeSpan.FromSeconds(submit_wait)).Until(ExpectedConditions.UrlContains("Portal"));
                Thread.Sleep(500);
                if (driver.Url != HomePageUrl)
                {
                    Console.WriteLine(driver.Title);
                    Console.WriteLine(driver.Url);
                    flag = false;
                }
                else
                {
                    Console.WriteLine(driver.Title);
                    Console.WriteLine(driver.Url);
                    flag = true;
                }
            }
            catch (Exception ex)
            {
                takescreenshot("exception login");
                Console.WriteLine(driver.Url);
                Console.WriteLine(ex.Message);
                flag = false;
            }
            takescreenshot("afterLoginScreen");
            return(flag);
        }
        /// <summary>
        /// Clicks the user-specified element and then waits for a window to close or open, or a page to load,
        /// depending on the element that was clicked
        /// </summary>
        /// <param name="buttonOrLinkElem">The button element</param>
        public void ClickAndWait(IWebElement buttonOrLinkElem)
        {
            // Error handler to make sure that the button that the tester passed in the parameter is actually on the page
            if (Browser.Exists(Bys.CBDLearnerPage.BackBtn))
            {
                // This is a workaround to be able to use an IF statement on an IWebElement type.
                if (buttonOrLinkElem.GetAttribute("outerHTML") == BackBtn.GetAttribute("outerHTML"))
                {
                    BackBtn.Click();
                    this.WaitForInitialize();
                    return;
                }
            }

            if (Browser.Exists(Bys.RCPPage.CBDTab))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == CBDTab.GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    this.WaitUntil(TimeSpan.FromSeconds(180), Criteria.CBDLearnerPage.PageReadyWithProgramLearningTabReady);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDLearnerPage.AddReflectBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AddReflectBtn.GetAttribute("outerHTML"))
                {
                    // NOTE: This sometimes does not work in Firefox whenever the tooltip for one of the tabs appears. Firefox
                    // fails to click when a tooltip is covering the button. However, this started working today. If it stops
                    // working again, we will have to implement a workaround in the SwitchTabs method
                    AddReflectBtn.Click();
                    WaitUtils.WaitForPopup(Browser, TimeSpan.FromSeconds(30), Bys.CBDLearnerPage.AddReflectFormContinueBtn);
                    //Browser.WaitForElement(Bys.CBDLearnerPage.AddReflectFormContinueBtn, ElementCriteria.IsVisible, ElementCriteria.IsEnabled);
                    this.WaitUntil(TimeSpan.FromSeconds(360), Criteria.CBDLearnerPage.LoadElementDoneLoading);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDLearnerPage.AddReflectFormContinueBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AddReflectFormContinueBtn.GetAttribute("outerHTML"))
                {
                    AddReflectFormContinueBtn.Click();
                    WaitUtils.WaitForPopup(Browser, TimeSpan.FromSeconds(30), Bys.CBDLearnerPage.AddReflectFormBrowseBtn);
                    this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading);
                    //Browser.WaitForElement(Bys.CBDLearnerPage.AddReflectFormBrowseBtn, ElementCriteria.IsVisible);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDLearnerPage.AddReflectFormSubmitBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AddReflectFormSubmitBtn.GetAttribute("outerHTML"))
                {
                    AddReflectFormSubmitBtn.Click();
                    this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.PageReadyWithReflectionsTabReady);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDLearnerPage.RequestObservationBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == RequestObservationBtn.GetAttribute("outerHTML"))
                {
                    RequestObservationBtn.Click();
                    WaitUtils.WaitForPopup(Browser, TimeSpan.FromSeconds(30), Bys.CBDLearnerPage.RequestObsFormObsNameTxt);
                    this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading);
                    //Browser.WaitForElement(Bys.CBDLearnerPage.RequestObsFormObsNameTxt, ElementCriteria.IsVisible, ElementCriteria.IsEnabled);
                    //Browser.WaitForElement(Bys.CBDLearnerPage.RequestObsFormSearchBtn, ElementCriteria.IsVisible, ElementCriteria.IsEnabled);
                    // Need to revisit the above 2 lines. For some reason, this needs a tiny static wait to work sometimes
                    //Thread.Sleep(0600);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDLearnerPage.RequestObsFormSearchBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == RequestObsFormSearchBtn.GetAttribute("outerHTML"))
                {
                    // 11/30/17: It failed today. Said "Failed to find any elements By.XPath: //tbody[@aria-label='Select Observer']"
                    // I looked on the screenshot and the radio button never got returned, even though the label beneath it said
                    // "Showing 1-1 of 1". This tells me that this is an application bug. Hopefully this fixes itself when DEV works
                    // on performance improvements. If not, and I see this again, I might have to add some more logic below to keep
                    // clicking or something else
                    // 11/05/17: For some reason, selenium sometimes fails to click this button. So I am adding a Catch and using javascript based click event if this fails
                    try
                    {
                        RequestObsFormSearchBtn.Click();
                        this.WaitUntilAll(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.RequestObsFormRdoBtnTbodyVisible,
                                          Criteria.CBDLearnerPage.RequestObsFormFirstRdoVisible);
                        this.WaitUntilAll(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading);
                        // Adding a Sleep here for now until I have time to come back and add some dynamic wait criteria
                        Thread.Sleep(0300);
                    }
                    catch
                    {
                        ((IJavaScriptExecutor)Browser).ExecuteScript("arguments[0].click()", RequestObsFormSearchBtn);
                        this.WaitForElement(Bys.CBDLearnerPage.RequestObsFormRdoBtnTbody, TimeSpan.FromSeconds(60), ElementCriteria.IsVisible);
                        this.WaitUntilAll(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading);
                        // Adding a Sleep here for now until I have time to come back and add some dynamic wait criteria
                        Thread.Sleep(0300);
                    }
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDLearnerPage.RequestObsFormRequestBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == RequestObsFormRequestBtn.GetAttribute("outerHTML"))
                {
                    RequestObsFormRequestBtn.Click();
                    this.WaitForElement(Bys.CBDLearnerPage.RequestObsFormOkBtn, ElementCriteria.IsVisible);
                    this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDLearnerPage.RequestObsFormOkBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == RequestObsFormOkBtn.GetAttribute("outerHTML"))
                {
                    RequestObsFormOkBtn.Click();
                    this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading);
                    return;
                }
            }

            if (Browser.Exists(Bys.RCPPage.LogoutLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == LogoutLnk.GetAttribute("outerHTML"))
                {
                    ElemSet.ScrollToElement(Browser, LogoutLnk);
                    LogoutLnk.Click();
                    new WebDriverWait(Browser, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.UrlContains("login"));
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDLearnerPage.AddReflectFormContinueBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AddReflectFormContinueBtn.GetAttribute("outerHTML"))
                {
                    AddReflectFormContinueBtn.Click();
                    WaitUtils.WaitForPopup(Browser, TimeSpan.FromSeconds(30), Bys.CBDLearnerPage.AddReflectFormBrowseBtn);
                    this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDLearnerPage.ViewMoreRptsLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == ViewMoreRptsLnk.GetAttribute("outerHTML"))
                {
                    ViewMoreRptsLnk.Click();
                    WaitUtils.WaitForPopup(Browser, TimeSpan.FromSeconds(30), Bys.CBDLearnerPage.ReportsFormShowBtn);
                    this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDLearnerPage.ReportsFormShowBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == ReportsFormShowBtn.GetAttribute("outerHTML"))
                {
                    ReportsFormShowBtn.Click();
                    Browser.WaitForElement(Bys.CBDLearnerPage.ReportsFormEPAObservCntChrt, ElementCriteria.IsVisible, ElementCriteria.IsEnabled, ElementCriteria.HasText);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDLearnerPage.ReportsFormCloseBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == ReportsFormCloseBtn.GetAttribute("outerHTML"))
                {
                    ReportsFormCloseBtn.Click();
                    this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.PageReadyWithProgramLearningTabReady);
                    return;
                }
            }

            else
            {
                throw new Exception("No button or link was found with your passed parameter. You either need to add this button to a new If statement, or " +
                                    "if the button is already added, then the page you were on did not contain the button.");
            }
        }
Example #7
0
        public void ValidarResultado()
        {
            Wait.Until(ExpectedConditions.UrlContains("https://cse.google.com/cse?"));

            StringAssert.Contains("https://cse.google.com/cse?", Driver.Url);
        }
Example #8
0
 public BingSearch ClickSubmit()
 {
     Root.GetElement(By.Id("sb_form_go"), message: "Can't search icn button").JsHighlight().Click();
     Root.Wait().Until(ExpectedConditions.UrlContains("search?"));
     return(new BingSearch());
 }
Example #9
0
 public bool UrlContains(string fraction)
 {
     return(ShortWait.Until(ExpectedConditions.UrlContains(fraction)));
 }
 public MyAccountPage WaitUntilPageIsLoaded()
 {
     Wait.Until(ExpectedConditions.UrlContains("https://myaccount.google.com/"));
     return(this);
 }
 /// <summary>
 /// Waits until browser window shows expected url.
 /// </summary>
 /// <param name="String">Url to wait for.</param>
 /// <returns>bool</returns>
 private bool WaitForUrlToContain(string String)
 {
     return(Wait.Until(ExpectedConditions.UrlContains(String)));
 }
Example #12
0
        public static bool WaitingFor_UrlContains(IWebDriver driver, string fraction, TimeSpan timeOut)
        {
            var wait = new WebDriverWait(driver, timeOut);

            return(wait.Until(ExpectedConditions.UrlContains(fraction)));
        }
Example #13
0
        public void ChangePassword()
        {
            WebDriverWait wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(10));

            WebDriver.Navigate().GoToUrl("https://newbookmodels.com/auth/signin");

            var email1 = WebDriver.FindElement(By.CssSelector("[type = email]"));

            email1.SendKeys("*****@*****.**");

            var password1 = WebDriver.FindElement(By.CssSelector("[type = password]"));

            password1.SendKeys("12345QWERTy_");

            var LogInButton1 = WebDriver.FindElement(By.CssSelector("button[class^= SignInForm]"));

            LogInButton1.Click();

            wait.Until(ExpectedConditions.UrlContains("Fexplore"));

            WebDriver.Navigate().GoToUrl("https://newbookmodels.com/account-settings/account-info/edit");

            var edit = WebDriver.FindElements(By.CssSelector("[class=edit-switcher__icon_type_edit]"))[2];

            edit.Click();

            var currentPassword = WebDriver.FindElement(By.CssSelector("input[placeholder*=Current]"));

            currentPassword.SendKeys("12345QWERTy_");

            var newPassword = WebDriver.FindElements(By.CssSelector("input[placeholder*=New]"))[0];

            newPassword.SendKeys("12345QWERTy_1");

            var retypeNewPassword = WebDriver.FindElements(By.CssSelector("input[placeholder*=New]"))[1];

            retypeNewPassword.SendKeys("12345QWERTy_1");


            var saveChanges = WebDriver.FindElements(By.CssSelector("button[class*=button_type_default]"))[1];

            saveChanges.Click();

            Thread.Sleep(1500);

            var logOut = WebDriver.FindElement(By.CssSelector("div[class*= link_type_logout]"));

            logOut.Click();

            WebDriver.Navigate().GoToUrl("https://newbookmodels.com/auth/signin");

            var email = WebDriver.FindElement(By.CssSelector("[type = email]"));

            email.SendKeys("*****@*****.**");

            var password = WebDriver.FindElement(By.CssSelector("[type = password]"));

            password.SendKeys("12345QWERTy_1");

            var LogInButton = WebDriver.FindElement(By.CssSelector("button[class^= SignInForm]"));

            LogInButton.Click();

            Thread.Sleep(1000);

            var actualResult = WebDriver.Url;

            Assert.AreEqual("https://newbookmodels.com/explore", actualResult);
        }
Example #14
0
 public void WaitUserSelect()
 {
     wait.Until(ExpectedConditions.ElementToBeClickable(By.ClassName("item")));
     wait.Until(ExpectedConditions.UrlContains("class-detail"));
 }
Example #15
0
 public static void ShouldLocate(IWebDriver webDriver, string location)
 {
     new WebDriverWait(webDriver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.UrlContains(location));
 }
Example #16
0
        /// <summary>
        /// Clicks the user-specified button, link, tab, etc. and then waits for a window to close or open, or a page to load,
        /// depending on the element that was clicked
        /// </summary>
        /// <param name="buttonOrLinkElem">The button element</param>
        public void ClickAndWait(IWebElement buttonOrLinkElem)
        {
            if (Browser.Exists(Bys.CBDProgDirectorPage.AddRemoveFlagFormRemoveFlagBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AddRemoveFlagFormRemoveFlagBtn.GetAttribute("outerHTML"))
                {
                    AddRemoveFlagFormRemoveFlagBtn.Click();
                    this.WaitUntilAll(TimeSpan.FromSeconds(60), Criteria.CBDProgDirectorPage.LearnersTblRowBodyVisibleAndEnabled,
                                      Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide,
                                      Criteria.CBDProgDirectorPage.LoadElementDisappeared);
                    return;
                }
            }

            if (Browser.Exists(Bys.RCPPage.CBDTab))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == Browser.FindElement(Bys.RCPPage.CBDTab).GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    this.WaitUntil(TimeSpan.FromSeconds(180), Criteria.CBDProgDirectorPage.PageReady);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDProgDirectorPage.AddRemoveFlagFormSaveFlagBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AddRemoveFlagFormSaveFlagBtn.GetAttribute("outerHTML"))
                {
                    AddRemoveFlagFormSaveFlagBtn.Click();
                    this.WaitUntilAll(TimeSpan.FromSeconds(60), Criteria.CBDProgDirectorPage.LearnersTblRowBodyVisibleAndEnabled,
                                      Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide,
                                      Criteria.CBDProgDirectorPage.LoadElementDisappeared);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDProgDirectorPage.SchedProgMeetFormScheduleBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == SchedProgMeetFormScheduleBtn.GetAttribute("outerHTML"))
                {
                    SchedProgMeetFormScheduleBtn.Click();
                    this.WaitUntilAll(TimeSpan.FromSeconds(60), Criteria.CBDProgDirectorPage.LearnersTblRowBodyVisibleAndEnabled,
                                      Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide,
                                      Criteria.CBDProgDirectorPage.LoadElementDisappeared);
                    this.WaitForInitialize();
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDProgDirectorPage.AddNotesFormSubmitBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AddNotesFormSubmitBtn.GetAttribute("outerHTML"))
                {
                    AddNotesFormSubmitBtn.Click();
                    this.WaitUntilAll(TimeSpan.FromSeconds(60), Criteria.CBDProgDirectorPage.LearnersTblRowBodyVisibleAndEnabled,
                                      Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide,
                                      Criteria.CBDProgDirectorPage.LoadElementDisappeared);
                    this.WaitForInitialize();
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDProgDirectorPage.AssignObsFormNextBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AssignObsFormNextBtn.GetAttribute("outerHTML"))
                {
                    AssignObsFormNextBtn.Click();
                    Browser.WaitForElement(Bys.CBDProgDirectorPage.AssignObsFormBackBtn, ElementCriteria.IsEnabled);
                    Browser.WaitForElement(Bys.CBDProgDirectorPage.AssignObsFormBackBtn, ElementCriteria.IsVisible);
                    Browser.WaitForElement(Bys.CBDProgDirectorPage.AssignObsFormBackBtn, ElementCriteria.HasText);
                    this.WaitForInitialize();
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDProgDirectorPage.AssignObsFormSearchBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AssignObsFormSearchBtn.GetAttribute("outerHTML"))
                {
                    AssignObsFormSearchBtn.Click();
                    Browser.WaitForElement(Bys.CBDProgDirectorPage.AssignObsFormObserverNameTxt, ElementCriteria.IsEnabled);
                    this.WaitForInitialize();
                    Thread.Sleep(1000);
                    this.WaitForInitialize();
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDProgDirectorPage.AssignObsFormAssignBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AssignObsFormAssignBtn.GetAttribute("outerHTML"))
                {
                    AssignObsFormAssignBtn.Click();
                    this.WaitForInitialize();
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDProgDirectorPage.CompCommiteeTab))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == CompCommiteeTab.GetAttribute("outerHTML"))
                {
                    CompCommiteeTab.Click();
                    // Note that the if this is a new environment, then this will fail because the Agenda table will not have any rows. You have to log in manually and create
                    // an agenda so that the agenda table gets rows
                    this.WaitUntilAll(TimeSpan.FromSeconds(60), Criteria.CBDProgDirectorPage.AgendaTblRowBodyVisibleAndEnabled,
                                      Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide, Criteria.CBDProgDirectorPage.LoadElementDisappeared);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDProgDirectorPage.CreateNewAgendaLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == CreateNewAgendaLnk.GetAttribute("outerHTML"))
                {
                    CreateNewAgendaLnk.Click();
                    this.WaitUntilAll(TimeSpan.FromSeconds(120), Criteria.CBDProgDirectorPage.CreateNewAgendaFormProgramSelElemHasItemsAndIsEnabled,
                                      Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide,
                                      Criteria.CBDProgDirectorPage.LoadElementDisappeared);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDProgDirectorPage.CreateNewAgendaFormCreateBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == CreateNewAgendaFormCreateBtn.GetAttribute("outerHTML"))
                {
                    CreateNewAgendaFormCreateBtn.Click();
                    this.WaitUntilAll(TimeSpan.FromSeconds(120), Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide,
                                      Criteria.CBDProgDirectorPage.LoadElementDisappeared);

                    // This failed once and the screenshot showed that the load element was still there. So the above wait criteria didnt work,
                    // maybe there is a second load icon that appears. So lets condition this so that if the form did not close yet, then wait
                    // again for the load icon to disappear.
                    if (Browser.FindElements(Bys.CBDProgDirectorPage.CreateNewAgendaFormCreateBtn).Count > 0)
                    {
                        this.WaitUntilAll(TimeSpan.FromSeconds(120), Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide,
                                          Criteria.CBDProgDirectorPage.LoadElementDisappeared);
                    }

                    return;
                }
            }

            if (Browser.Exists(Bys.CBDProgDirectorPage.SetStatusFormConfirmBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == SetStatusFormConfirmBtn.GetAttribute("outerHTML"))
                {
                    SetStatusFormConfirmBtn.Click();
                    this.WaitUntilAll(TimeSpan.FromSeconds(60), Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide,
                                      Criteria.CBDProgDirectorPage.LoadElementDisappeared);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDProgDirectorPage.FinalizeAgendaBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == FinalizeAgendaBtn.GetAttribute("outerHTML"))
                {
                    FinalizeAgendaBtn.Click();
                    this.WaitUntilAll(TimeSpan.FromSeconds(60), Criteria.CBDProgDirectorPage.FinalizeAgendaFormFinalizeBtnIsEnabled,
                                      Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide, Criteria.CBDProgDirectorPage.LoadElementDisappeared);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDProgDirectorPage.FinalizeAgendaFormFinalizeBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == FinalizeAgendaFormFinalizeBtn.GetAttribute("outerHTML"))
                {
                    FinalizeAgendaFormFinalizeBtn.Click();
                    this.WaitUntilAll(TimeSpan.FromSeconds(60), Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide,
                                      Criteria.CBDProgDirectorPage.LoadElementDisappeared, Criteria.CBDProgDirectorPage.AgendaTblRowBodyVisibleAndEnabled);
                    return;
                }
            }

            if (Browser.Exists(Bys.RCPPage.LogoutLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == LogoutLnk.GetAttribute("outerHTML"))
                {
                    ElemSet.ScrollToElement(Browser, LogoutLnk);
                    LogoutLnk.Click();
                    new WebDriverWait(Browser, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.UrlContains("login"));
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDProgDirectorPage.AddSupportingDocumentationFormSubmitBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AddSupportingDocumentationFormSubmitBtn.GetAttribute("outerHTML"))
                {
                    AddSupportingDocumentationFormSubmitBtn.Click();
                    this.WaitUntilAll(Criteria.CBDProgDirectorPage.LearnersTblRowBodyVisibleAndEnabled,
                                      Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide,
                                      Criteria.CBDProgDirectorPage.LoadElementDisappeared);
                    return;
                }
            }

            else
            {
                throw new Exception("No button or link was found with your passed parameter. You either need to add this button to a new If statement, " +
                                    "or if the button is already added, then the page you were on did not contain the button.");
            }
        }
Example #17
0
 protected void NavigateToPage(string url)
 {
     driver.Navigate().GoToUrl(url);
     new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.UrlContains(url));
 }
Example #18
0
 internal static void UrlContains(string partOfUrl)
 => Wait.Until(ExpectedConditions.UrlContains(partOfUrl));
Example #19
0
 public void CheckUrl(string expectedUrl)
 {
     Assert.DoesNotThrow(() => { context.Waitings.Get(Waitings.Normal).Until(ExpectedConditions.UrlContains(expectedUrl)); },
                         "Ожидалось, что url будет содержать '{0}', получено - '{1}'", expectedUrl, context.Driver.Url);
 }
Example #20
0
 public void ThenBrowserTitleContains(string fraction)
 {
     AllureLifecycle.Instance.WrapInStep(
         () => { Driver.Wait().Until(ExpectedConditions.UrlContains(fraction)); },
         $"Validating that title contains {fraction}");
 }
 public void UrlToContain(string url)
 {
     new WebDriverWait(_webDriver, TimeSpan.FromMilliseconds(_waitMs))
     .Until(ExpectedConditions.UrlContains(url));
 }
Example #22
0
 /// <summary>
 /// Pauses execution until the url contains a given string
 /// </summary>
 /// <param name="text">The text to use in comparison.</param>
 /// <returns>True if the URL contains the given text, false if the wait expires.</returns>
 public bool WaitForUrlToContain(string text)
 {
     try
     {
         var wait = new WebDriverWait(Driver, Preferences.BaseSettings.Timeout).Until(ExpectedConditions.UrlContains(text));
         if (wait == false)
         {
             throw new Exception("Could not confirm staleness of the element required.");
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        /// <summary>
        /// Clicks the user-specified element and then waits for a window to close or open, or a page to load,
        /// depending on the element that was clicked
        /// </summary>
        /// <param name="buttonOrLinkElem">The button element</param>
        public void ClickAndWait(IWebElement buttonOrLinkElem)
        {
            if (Browser.Exists(Bys.CBDObserverPage.AccDecAssgnMntFormAcceptBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AccDecAssgnMntFormAcceptBtn.GetAttribute("outerHTML"))
                {
                    AccDecAssgnMntFormAcceptBtn.Click();
                    this.WaitForInitialize();
                    // 9/18/17 Commented the following line. Im pretty sure this is not needed anymore, because I implemented this wait in the PageCriteria class
                    Browser.WaitForElement(Bys.RCPPage.LoadIcon, TimeSpan.FromSeconds(60), ElementCriteria.AttributeValue("class", "page-splash dissolve-animation ng-hide")
                                           .OR(ElementCriteria.AttributeValue("class", "page-splash dissolve-animation ng-animate ng-hide")));
                    return;
                }
            }

            if (Browser.Exists(Bys.RCPPage.CBDTab))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == CBDTab.GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    this.WaitUntil(Criteria.CBDObserverPage.PageReady);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDObserverPage.AccDecAssgnMntFormDeclineBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AccDecAssgnMntFormDeclineBtn.GetAttribute("outerHTML"))
                {
                    AccDecAssgnMntFormDeclineBtn.Click();
                    Browser.WaitForElement(Bys.CBDObserverPage.ConfirmFormCompleteAssessYesBtn, ElementCriteria.IsEnabled);
                    this.WaitForInitialize();
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDObserverPage.ConfirmFormRemoveAssessOkBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == ConfirmFormRemoveAssessOkBtn.GetAttribute("outerHTML"))
                {
                    ConfirmFormRemoveAssessOkBtn.Click();
                    this.WaitForInitialize();
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDObserverPage.ConfirmFormDeclineAssessYesBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == ConfirmFormDeclineAssessYesBtn.GetAttribute("outerHTML"))
                {
                    ConfirmFormDeclineAssessYesBtn.Click();
                    this.WaitForInitialize();
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDObserverPage.CompleteAssessFormSubmitBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == CompleteAssessFormSubmitBtn.GetAttribute("outerHTML"))
                {
                    CompleteAssessFormSubmitBtn.Click();
                    this.WaitForInitialize();
                    Browser.WaitForElement(Bys.CBDObserverPage.ConfirmFormCompleteAssessYesBtn, ElementCriteria.IsEnabled);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDObserverPage.ConfirmFormCompleteAssessYesBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == ConfirmFormCompleteAssessYesBtn.GetAttribute("outerHTML"))
                {
                    ConfirmFormCompleteAssessYesBtn.Click();
                    this.WaitForInitialize();
                    return;
                }
            }

            if (Browser.Exists(Bys.RCPPage.LogoutLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == LogoutLnk.GetAttribute("outerHTML"))
                {
                    LogoutLnk.Click();
                    new WebDriverWait(Browser, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.UrlContains("login"));
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDObserverPage.AddObservationBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AddObservationBtn.GetAttribute("outerHTML"))
                {
                    AddObservationBtn.Click();
                    WaitUtils.WaitForPopup(Browser, TimeSpan.FromSeconds(30), Bys.CBDObserverPage.AddObsFormSearchBtn);
                    this.WaitForInitialize();
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDObserverPage.AddObsFormSearchBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AddObsFormSearchBtn.GetAttribute("outerHTML"))
                {
                    AddObsFormSearchBtn.Click();
                    WaitUtils.WaitForPopup(Browser, TimeSpan.FromSeconds(30), Bys.CBDObserverPage.AddObsFormObsTblFacultyColHdr);
                    this.WaitForInitialize();
                    Thread.Sleep(1000);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDObserverPage.AddObsFormNextBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AddObsFormNextBtn.GetAttribute("outerHTML"))
                {
                    AddObsFormNextBtn.Click();
                    Browser.WaitForElement(Bys.CBDObserverPage.AddObsFormBackBtn, ElementCriteria.IsEnabled);
                    Browser.WaitForElement(Bys.CBDObserverPage.AddObsFormBackBtn, ElementCriteria.IsVisible);
                    Browser.WaitForElement(Bys.CBDObserverPage.AddObsFormBackBtn, ElementCriteria.HasText);
                    this.WaitForInitialize();
                    return;
                }
            }

            else
            {
                throw new Exception("No button or link was found with your passed parameter. You either need to add this button to a new If statement, " +
                                    "or if the button is already added, then the page you were on did not contain the button.");
            }
        }
Example #24
0
        /// <summary>
        /// Clicks the user-specified button, link, tab, etc. and then waits for a window to close or open, or a page to load,
        /// depending on the element that was clicked
        /// </summary>
        /// <param name="buttonOrLinkElem">The button element</param>
        public void ClickAndWait(IWebElement buttonOrLinkElem)
        {
            if (Browser.Exists(Bys.CBDProgDeanPage.LearnersTab))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == LearnersTab.GetAttribute("outerHTML"))
                {
                    LearnersTab.Click();
                    this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDProgDeanPage.LearnersTblBodyRowVisibleAndEnabled);
                    this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDProgDeanPage.LoadElementDoneLoading);
                    return;
                }
            }

            if (Browser.Exists(Bys.RCPPage.CBDTab))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == Browser.FindElement(Bys.RCPPage.CBDTab).GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    this.WaitUntil(TimeSpan.FromSeconds(180), Criteria.CBDProgDeanPage.PageReady);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDProgDeanPage.AddRemoveFlagFormRemoveFlagBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AddRemoveFlagFormRemoveFlagBtn.GetAttribute("outerHTML"))
                {
                    AddRemoveFlagFormRemoveFlagBtn.Click();
                    this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDProgDeanPage.LearnersTblBodyRowVisibleAndEnabled);
                    this.WaitUntil(Criteria.CBDProgDeanPage.LoadElementDoneLoading);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDProgDeanPage.AddRemoveFlagFormSaveFlagBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AddRemoveFlagFormSaveFlagBtn.GetAttribute("outerHTML"))
                {
                    AddRemoveFlagFormSaveFlagBtn.Click();
                    this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDProgDeanPage.LearnersTblBodyRowVisibleAndEnabled);
                    this.WaitUntil(Criteria.CBDProgDeanPage.LoadElementDoneLoading);
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDProgDeanPage.AddNotesFormSubmitBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AddNotesFormSubmitBtn.GetAttribute("outerHTML"))
                {
                    AddNotesFormSubmitBtn.Click();
                    this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDProgDeanPage.LearnersTblBodyRowVisibleAndEnabled);
                    this.WaitUntil(Criteria.CBDProgDeanPage.LoadElementDoneLoading);
                    return;
                }
            }

            if (Browser.Exists(Bys.RCPPage.LogoutLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == LogoutLnk.GetAttribute("outerHTML"))
                {
                    ElemSet.ScrollToElement(Browser, LogoutLnk);
                    LogoutLnk.Click();
                    new WebDriverWait(Browser, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.UrlContains("login"));
                    return;
                }
            }

            if (Browser.Exists(Bys.CBDProgDeanPage.AddSupportingDocumentationFormSubmitBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AddSupportingDocumentationFormSubmitBtn.GetAttribute("outerHTML"))
                {
                    AddSupportingDocumentationFormSubmitBtn.Click();
                    this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDProgDeanPage.LearnersTblBodyRowVisibleAndEnabled);
                    this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDProgDeanPage.LoadElementDoneLoading);
                    return;
                }
            }

            else
            {
                throw new Exception("No button or link was found with your passed parameter. You either need to add this button to a new If statement, " +
                                    "or if the button is already added, then the page you were on did not contain the button.");
            }
        }
 protected void _waitUntilUserIsRedirected(string partOfUrlAfterBase, RemoteWebDriver driver)
 {
     _getWebDriverWait(driver).Until(ExpectedConditions.UrlContains(partOfUrlAfterBase));
 }