public void FillLocationOfEvent(string location)
        {
            wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#location")));
            wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("#location")));
            bool      textNotEntered = true;
            Stopwatch timer          = new Stopwatch();

            timer.Start();
            while (textNotEntered)
            {
                locationOfEvent.SendKeys(location);
                try
                {
                    wait.Until(ExpectedConditions.TextToBePresentInElementValue(locationOfEvent, location));
                    textNotEntered = false;
                }
                catch (WebDriverTimeoutException t)
                {
                    locationOfEvent.Clear();
                }
                if (timer.Elapsed.Seconds > 10)
                {
                    textNotEntered = false;
                    ReportLog.Fail("Couldn't input location.");
                    throw new WebDriverTimeoutException("Couldn't input location.");
                }
            }
            Assert.AreEqual(location, locationOfEvent.GetAttribute("value"));
            ReportLog.Log("Filled location of event as: " + location);
        }
Exemplo n.º 2
0
        public void validateLoadPage()
        {
            ReportLog.Log(LogStatus.Pass, "Test started");
            HomePage homepage = new HomePage(getDriver);

            Assert.IsTrue(homepage.getTitle().Text == "Become A Full-Stack .Net Developer", "Title not matched");
        }
        public void ClickBurnAilment()
        {
            burnAilment.Click();
            var burn = driver.FindElement(By.CssSelector("#detail_desc_table > tbody > tr > td:nth-child(4)")).Text;

            Assert.AreEqual("Burn", burn);
            ReportLog.Log("Clicked burn ailment");
        }
        public void SelectPersonReporting()
        {
            var personReportingSelectElement = new SelectElement(this.personReportingSelect);

            personReportingSelectElement.SelectByIndex(1);
            Assert.AreEqual("Worker", personReportingSelectElement.SelectedOption.Text);
            ReportLog.Log("Selected Person Reporting as " + personReportingSelectElement.SelectedOption.Text);
        }
        public void SetEventDate(string date)
        {
            eventDate.SendKeys(date);
            wait.Until(ExpectedConditions.TextToBePresentInElementValue(eventDate, date));
            var dateValue = eventDate.GetAttribute("value");

            Assert.AreEqual(date, dateValue);
            ReportLog.Log("Set event date as: " + date);
        }
        public void EditAnEventItem()
        {
            // Set up the test in ReportLog wrapper class.
            ReportLog.CreateTest("EditAnEventItem", "This is an end-to-end test case regarding the editing of an Event.");
            try
            {
                // Log in.
                LoginPage loginPage = new LoginPage(driver);
                loginPage.NavigateToLoginPage();
                ReportLog.Log("Navigated to Login Page.");
                loginPage.TypeUserName("plan.6");
                loginPage.TypePassword("plan01#");
                ReportLog.Log("Entered credentials.");

                // Go to home page.
                HomePage homePage = loginPage.ConfirmLoginAndGoBackToHomePage();
                homePage.WaitUntilHomePageLoadingComplete();
                ReportLog.Log("Login confirmed and redirected back to Home Page.");

                // Go to events page.
                EventsPage eventsPage = homePage.GoToEventsPage();
                eventsPage.WaitUntilEventsPageLoadingComplete();
                ReportLog.Log("Navigated to Events Page.");

                // Go to event item page of a specific item.
                EventsItemPage eventsItemPage = eventsPage.GoToSpecificEventsItemPage(0);
                eventsItemPage.WaitUntilEventsItemPageLoadingComplete();
                ReportLog.Log("Go to the editing page of a specific item.");

                // Input mandatory values, save changes and extract item reference ID.
                string referenceID = eventsItemPage.InputMandatoryChangesAndSave().Substring(13);
                ReportLog.Log("Mandatory fields inputted and changes saved.");

                // Search for this specific item.
                eventsPage.SearchByReferenceID(referenceID, false, true);
                try
                {
                    // Assertion.
                    eventsPage.ConfirmEventEdited(referenceID);
                    ReportLog.Pass("EditAnEventItem.");
                }
                catch (AssertionException a)
                {
                    // Test failed due to assertion error.
                    ReportLog.Fail(a.Message, ReportLog.TakeScreenShot("AddAnEventItemViaPortal", driver));
                    throw a;
                }
                driver.Quit();
            }
            catch (Exception e)
            {
                // Test failed due to unforeseen exception.
                ReportLog.Fail(e.Message + "\n" + e.StackTrace);
                ReportLog.Fail("UnforeseenException", ReportLog.TakeScreenShot("UnforeseenException", driver));
                throw e;
            }
        }
        public void SelectSubject()
        {
            var subjectSelectElement = new SelectElement(subjectSelect);

            subjectSelectElement.SelectByIndex(2);
            string selectedSubject = subjectSelectElement.SelectedOption.Text;

            Assert.AreEqual("Biological agencies", selectedSubject);
            ReportLog.Log("Selected the subject: Biological agencies.");
        }
        public void ClickSaveButton()
        {
            saveButton.Click();
            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.CssSelector("#vaultModal > div > div > div.modal-header > h4")));
            string success = driver.FindElement(By.CssSelector("#vaultModal > div > div > div.modal-body > p")).Text;

            Assert.AreEqual("Thank you for submitting this event. Your Item Reference is:", success.Substring(0, 60));
            ReportLog.Log("Clicked save button.");
            referenceID = referenceIDElement.Text;
        }
        public void ClickRespiratoryRadioButton()
        {
            respiratoryRadioButtonLink.Click();
            wait.Until(ExpectedConditions.ElementIsVisible(
                           By.CssSelector("#body-area-data-table > tbody > tr.odd.active > td")));
            IWebElement lungs = driver.FindElement(By.CssSelector("#body-area-data-table > tbody > tr.odd.active > td"));

            Assert.AreEqual("Lungs", lungs.Text);
            ReportLog.Log("Clicked respiratory radio button");
        }
 public void SelectPersonReportingName()
 {
     personReportingName.SendKeys("Charles Worker");
     Assert.AreEqual("Charles Worker", personReportingName.GetAttribute("value"));
     ReportLog.Log("Input name \"Charles Worker\".");
     wait.Until(ExpectedConditions.ElementIsVisible(By.PartialLinkText("Charles Worker")));
     driver.FindElement(By.PartialLinkText("Charles Worker")).Click();
     Assert.AreEqual("Charles Worker", personReportingName.GetAttribute("value"));
     ReportLog.Log("Selected person reporting name as: \"Charles Worker\"");
 }
 public void AddAnEventItemViaPortal()
 {
     // Set up the test in ReportLog wrapper class.
     ReportLog.CreateTest("AddAnEventItemViaPortal",
                          "This is an end-to-end test case regarding the adding of an Event via the Portal.");
     try
     {
         // Add from portal.
         var portalPage = new PortalPage(driver);
         portalPage.NavigateToPortalPage();
         // Fill out and save a new report.
         portalPage.ReportAnInjury();
         // Login in order to check Event has been added.
         var loginPage = new LoginPage(driver);
         loginPage.NavigateToLoginPage();
         var homePage = loginPage.LoginWithCredentials("plan.8", "plan01#");
         ReportLog.Log("Submitted login details.");
         // Now check if the event has been added.
         var eventsPage = new EventsPage(driver);
         eventsPage.NavigateToEventsPage();
         ReportLog.Log("Navigated to Events page.");
         eventsPage.SearchByReferenceID(portalPage.GetReferenceID(), true, true);
         ReportLog.Log("Searched for reference ID: " + portalPage.GetReferenceID());
         try
         {
             // Confirm Event has been added.
             eventsPage.ConfirmEventAdded(portalPage.GetReferenceID());
             ReportLog.Pass("AddAnEventItemViaPortal Test Passed.");
         }
         catch (AssertionException a)
         {
             // Test failed due to assertion error.
             ReportLog.Fail(a.Message + "\n" + a.StackTrace, ReportLog.TakeScreenShot("AddAnEventItemViaPortal", driver));
             throw a;
         }
         driver.Quit();
     }
     catch (Exception e)
     {
         // Test failed due to unforeseen exception.
         ReportLog.Fail(e.Message + "\n" + e.StackTrace, ReportLog.TakeScreenShot("UnforeseenException", driver));
         throw e;
     }
 }
 public void ReportAnInjury()
 {
     ClickReportInjuryArrowButton();
     SelectPersonReporting();
     SelectPersonReportingName();
     ClickPersonInvolved();                       // This fills person involved automatically as above.
     FillLocationOfEvent("TEST location");
     SetEventDate("02/05/2018");
     SetEventTime("12:05");
     SelectSubject();
     FillWhatHappened("TEST what happened");
     FillWhoElseWasInvolved("TEST who else was involved");
     FillInitialActions("TEST initial actions");
     ClickRespiratoryRadioButton();
     ClickMouthBodyArea();
     ClickBurnAilment();
     ClickSaveButton();
     ReportLog.Log("Filled out report an injury.");
 }
 public void FillPersonInvolvedName(string name)
 {
     personInvolvedName.SendKeys(name);
     Assert.AreEqual(name, personInvolvedName.GetAttribute("value"));
     ReportLog.Log("Filled person involved name as: " + name);
 }
 public void NavigateToPortalPage()
 {
     driver.Navigate().GoToUrl(Url);
     Assert.AreEqual(PortalPage.Url, driver.Url);
     ReportLog.Log("Navigated to portal page.");
 }
 public void ClickMouthBodyArea()
 {
     mouthBodyArea.Click();
     Assert.AreEqual("even active", mouthBodyArea.GetAttribute("class"));
     ReportLog.Log("Clicked mouth body area");
 }
 public void FillInitialActions(string text)
 {
     initialActionsTextBox.SendKeys(text);
     Assert.AreEqual(text, initialActionsTextBox.GetAttribute("value"));
     ReportLog.Log("Filled what intial actions as: " + text);
 }
 public void ClickEventHappenedOffsitCheckbox()
 {
     eventHappenedOffsitCheckbox.Click();
     Assert.True(eventHappenedOffsitCheckbox.Selected);
     ReportLog.Log("Clicked \"event happened offsite\".");
 }
 public void FillWhoElseWasInvolved(string text)
 {
     whoElseWasInvolvedTextBox.SendKeys(text);
     Assert.AreEqual(text, whoElseWasInvolvedTextBox.GetAttribute("value"));
     ReportLog.Log("Fill who else was involved as: " + text);
 }
 public void ClickPersonInvolved()
 {
     personInvolvedSelect.Click();
     Assert.AreEqual("Employee", personInvolvedSelect.GetAttribute("value"));
     ReportLog.Log("Clicked the person involved select element.");
 }
 public void SetEventTime(string time)
 {
     eventTime.SendKeys(time);
     Assert.AreEqual(time, eventTime.GetAttribute("value"));
     ReportLog.Log("Set event time as: " + time);
 }
 public void FillPersonReportingName(string name)
 {
     personReportingName.SendKeys(name);
     Assert.AreEqual(name, personReportingName.GetAttribute("value"));
     ReportLog.Log("Entered person reporting name as: " + name);
 }
 public void ClickSensitiveEvent()
 {
     sensitiveEventCheckbox.Click();
     Assert.True(sensitiveEventCheckbox.Selected);
     ReportLog.Log("Clicked sensitive event.");
 }
 public void FillWhatHappened(string text)
 {
     whatHappenedTextBox.SendKeys(text);
     Assert.AreEqual(text, whatHappenedTextBox.GetAttribute("value"));
     ReportLog.Log("Filled what happened as: " + text);
 }
 public void ClickReportInjuryArrowButton()
 {
     reportInjuryArrowButton.Click();
     Assert.AreEqual(ReportInjuryUrl, driver.Url);
     ReportLog.Log("Clicked report an injury arrow button");
 }