public void ClearCompleted()
        {
            AddToDo("ToDoToBeCleared");
            AddToDo("SecondToDoToNotBeCleared");


            NgWebElement toDoList = ngDriver.FindElement(By.Id("todo-list"));

            Assert.AreEqual(2, toDoList.FindElements(By.CssSelector("li")).Count, "to-do's weren't created");

            NgWebElement item = toDoList.FindElement(By.CssSelector("li"));

            WebDriverWait wait = new WebDriverWait(ngDriver, new TimeSpan(0, 0, 15));

            wait.Until(ExpectedConditions.ElementToBeClickable(item.FindElement(NgBy.Model("todo.completed"))));

            Assert.True(!item.GetAttribute("class").Contains("completed"), "item was already set to completed without being clicked");

            item.FindElement(NgBy.Model("todo.completed")).Click();

            Assert.True(item.GetAttribute("class").Contains("completed"), "item is still not to completed after it has been clicked");

            wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("clear-completed")));

            ngDriver.FindElement(By.Id("clear-completed")).Click();

            Assert.AreEqual(1, toDoList.FindElements(By.CssSelector("li")).Count, "to-do wasn't deleted");
        }
        public void FilterByCompleted()
        {
            AddToDo("ToDoToBeFiltered");
            AddToDo("SecondToDoToNotBeFiltered");

            NgWebElement toDoList = ngDriver.FindElement(By.Id("todo-list"));

            Assert.AreEqual(2, toDoList.FindElements(By.CssSelector("li")).Count, "to-do's weren't created");

            NgWebElement item = toDoList.FindElement(By.CssSelector("li"));

            Assert.True(!item.GetAttribute("class").Contains("completed"), "item was already set to completed without being clicked");


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

            wait.Until(ExpectedConditions.ElementToBeClickable(item.FindElement(NgBy.Model("todo.completed"))));

            item.FindElement(NgBy.Model("todo.completed")).Click();

            Assert.True(item.GetAttribute("class").Contains("completed"), "item is still not to completed after it has been clicked");

            NgWebElement filters = ngDriver.FindElement(By.Id("filters"));

            filters.FindElement(By.CssSelector("a[href='#/completed']")).Click();


            //changing the filter reloaded the todo list from scratch causing a stale todo list element
            Assert.AreEqual(1, ngDriver.FindElement(By.Id("todo-list")).FindElements(By.CssSelector("li")).Count, "to-do wasn't filtered");
        }
        public void UncompleteToDo()
        {
            AddToDo("ToDoToBeSetBackToACtive");

            NgWebElement toDoList = ngDriver.FindElement(By.Id("todo-list"));

            Assert.AreEqual(1, toDoList.FindElements(By.CssSelector("li")).Count, "to-do wasn't created");
            NgWebElement item = toDoList.FindElement(By.CssSelector("li"));


            WebDriverWait wait = new WebDriverWait(ngDriver, new TimeSpan(0, 0, 15));

            wait.Until(ExpectedConditions.ElementToBeClickable(item.FindElement(NgBy.Model("todo.completed"))));

            item.FindElement(NgBy.Model("todo.completed")).Click();


            //issue was caused in edge attemted to fix with commented out code but basically the clicks whould happen too fast and the seond wouldnt be recognised
            Thread.Sleep(1000);

            Assert.True(item.GetAttribute("class").Contains("completed"), "to-do wasn't set to completed");
            wait.Until(ExpectedConditions.ElementToBeClickable(item.FindElement(NgBy.Model("todo.completed"))));

            item.FindElement(NgBy.Model("todo.completed")).Click();

            //ngDriver.WaitForAngular();

            Assert.True(!item.GetAttribute("class").Contains("completed"), "to-do wasn't set to active");
        }
        public void CompleteToDo()
        {
            AddToDo("ToDoToBeCompleted");
            NgWebElement toDoList = ngDriver.FindElement(By.Id("todo-list"));

            Actions      act  = new Actions(ngDriver);
            NgWebElement item = toDoList.FindElement(By.CssSelector("li"));

            Assert.True(!item.GetAttribute("class").Contains("completed"), "item was already set to completed without being clicked");

            item.FindElement(NgBy.Model("todo.completed")).Click();

            Assert.True(item.GetAttribute("class").Contains("completed"), "item is still not to completed after it has been clicked");
        }
        public void AutoRenewalDenied()
        {
            string renewLicence = "Transfer Licence";

            // find the Transfer Licence link
            NgWebElement uiLicenceID = ngDriver.FindElement(By.LinkText(renewLicence));
            string       URL         = uiLicenceID.GetAttribute("href");

            // retrieve the licence ID
            string[] parsedURL = URL.Split('/');

            licenceID = parsedURL[5];

            ngDriver.IgnoreSynchronization = true;

            // navigate to api/Licenses/noautorenew/{licenceID}
            ngDriver.Navigate().GoToUrl($"{baseUri}api/Licenses/noautorenew/{licenceID}");

            if (!ngDriver.WrappedDriver.PageSource.Contains("OK"))
            {
                throw new Exception(ngDriver.WrappedDriver.PageSource);
            }

            ngDriver.IgnoreSynchronization = false;

            // navigate back to Licenses tab
            ngDriver.Navigate().GoToUrl($"{baseUri}licences");
        }
Exemple #6
0
        public void ExpiryDateToday()
        {
            string transferLicence = "Transfer Licence";

            // find the Transfer Licence link
            NgWebElement uiLicenceID = ngDriver.FindElement(By.LinkText(transferLicence));
            string       URL         = uiLicenceID.GetAttribute("href");

            // retrieve the licence ID
            string[] parsedURL = URL.Split('/');

            licenceID = parsedURL[5];

            ngDriver.IgnoreSynchronization = true;

            // navigate to api/Licenses/<Licence ID>/setexpiry
            ngDriver.Navigate().GoToUrl($"{baseUri}api/Licenses/{licenceID}/setexpiry");

            // wait for the automated expiry process to run
            Assert.True(ngDriver.FindElement(By.XPath("//body[contains(.,'OK')]")).Displayed);

            ngDriver.IgnoreSynchronization = false;

            // navigate back to Licenses tab
            ngDriver.Navigate().GoToUrl($"{baseUri}licences");
        }
Exemple #7
0
        public void FirstTest()
        {
            driver.Navigate().GoToUrl(URL);
            ngDriver.WaitForAngular();

            //Find product price text box using the ng-model
            NgWebElement ProductPrice = ngDriver.FindElement(NgBy.Model("productPrice"));

            ProductPrice.SendKeys(TestContext.DataRow["ProductPrice"].ToString());
            Thread.Sleep(2000);

            //Find discount text box using the ng-model
            NgWebElement DiscountOnProduct = ngDriver.FindElement(NgBy.Model("discountPercent"));

            DiscountOnProduct.SendKeys(TestContext.DataRow["DiscountOnProduct"].ToString());
            Thread.Sleep(2000);

            //Find button using selenium locator XPath
            NgWebElement BtnPriceAfterDiscount = ngDriver.FindElement(By.XPath("//*[@id='f1']/fieldset[2]/input[1]"));

            BtnPriceAfterDiscount.Click();
            Thread.Sleep(2000);

            //Find discounted product text box using the ng-model
            NgWebElement afterDiscountValue = ngDriver.FindElement(NgBy.Model("afterDiscount"));
            string       value = afterDiscountValue.GetAttribute("value");

            Thread.Sleep(2000);

            //Assert for corect value
            Assert.AreEqual <string>(TestContext.DataRow["AfterDiscountPrice"].ToString(), value);
        }
Exemple #8
0
        public void checkname()
        {
            ngdriver.WaitForAngular();
            NgWebElement profilename = ngdriver.FindElement(By.CssSelector("#DeltaPlaceHolderMain > app-intry > app-header > div > div > div.pull-right > div > span"));
            String       name        = profilename.GetAttribute("innerText");

            Console.WriteLine(name);
            Assert.AreEqual(name, "Ivan Lesnikov");
        }
        public static void EnterText(IWebElement webElement, string text)
        {
            webElement = new NgWebElement(driver, webElement);
            var log         = ScenarioContext.Current.Get <TextWriterTraceListener>("report");
            var i           = Int32.Parse(ScenarioContext.Current["stepcounter"].ToString());
            var placeholder = webElement.GetAttribute("placeholder");

            if (placeholder.Length == 0)
            {
                placeholder = webElement.GetAttribute("id");
            }

            if (text.Length > 0)
            {
                if (text[text.Length - 1] > (char)57349)
                {
                    log.WriteLine(
                        i++ + ". And I entered '" + text.TrimEnd().Substring(0, text.Length - 1) + "' in '"
                        + placeholder + "' field");
                    log.WriteLine("-----------------------------------------------------------");
                    log.WriteLine(i++ + ". Then I pressed 'ENTER'");
                }
                else
                {
                    log.WriteLine(i++ + ". And I entered '" + text + "' in '" + placeholder + "' field");
                }
            }
            else
            {
                log.WriteLine(i++ + ". And I left field '" + placeholder + "' blank");
            }
            webElement.Click();
            //webElement.Clear();
            webElement.SendKeys(text);
            log.WriteLine("-----------------------------------------------------------");
            log.Close();
            ScenarioContext.Current["stepcounter"] = i;
        }
Exemple #10
0
        public void notificationCount()
        {
            ngdriver.WaitForAngular();
            NgWebElement notifyCount = ngdriver.FindElement(By.CssSelector(cssNotify));
            String       notCount    = notifyCount.GetAttribute("innerText");

            Console.WriteLine(notCount);
            notifyCount.Click();
            //Assert.AreEqual(true, ngdriver.FindElement(By.CssSelector("#DeltaPlaceHolderMain > app-intry > app-header > div > div > div.pull-right > app-notifications > div > div")).Displayed);

            //NgWebElement markREAD = ngdriver.FindElement(By.CssSelector("#DeltaPlaceHolderMain > app-intry > app-header > div > div > div.pull-right > app-notifications > div > div > div.notification__header > a"));
            //markREAD.Click();

            //Assert.AreEqual(false, notifyCount.Displayed);
        }
Exemple #11
0
        /// <summary>
        /// it isn't finished
        /// </summary>
        /// <param name="element"></param>
        /// <param name="attributeName"></param>
        /// <param name="attributeValue"></param>
        /// <param name="timeout"></param>
        public void WaitAttributeElements(NgWebElement element, string attributeName, string attributeValue, int timeout = 5000)
        {
            var      waitTime = 100;
            DateTime tend     = DateTime.Now.AddMilliseconds(timeout);

            do
            {
                System.Threading.Thread.Sleep(waitTime);
                if (element.GetAttribute(attributeName) == attributeValue)
                {
                    return;
                }
            } while (DateTime.Now <= tend);

            Assert.Fail("Element {0} was not hidden during time {1} ms.", element, timeout);
        }
        public string GetElementValue(string elementID, int maxSeconds)
        {
            NgWebElement element   = ngDriver.FindElement(By.Id(elementID));
            int          waitCount = 0;

            var actual = element.GetAttribute("value");



            while (!element.Displayed && ++waitCount <= maxSeconds)
            {
                System.Threading.Thread.Sleep(5000);
                element = GetElement(elementID);
            }

            return(actual);
        }
Exemple #13
0
        public void TestMethod1()
        {
            ngdriver.Url = URL;
            ngdriver.WaitForAngular();

            //Find product price text box using the ng-model
            NgWebElement ProductPrice = ngdriver.FindElement(NgBy.Model("productPrice"));

            ProductPrice.SendKeys("799");
            Thread.Sleep(2000);


            //Find discount text box using the ng-model
            NgWebElement DiscountOnProduct = ngdriver.FindElement(NgBy.Model("discountPercent"));

            DiscountOnProduct.SendKeys("10");
            Thread.Sleep(2000);


            //Find button using selenium locator XPath
            NgWebElement BtnPriceAfterDiscount = ngdriver.FindElement(By.XPath("//*[@id='f1']/fieldset[2]/input[1]"));

            BtnPriceAfterDiscount.Click();
            Thread.Sleep(2000);


            //Find discounted product text box using the ng-model
            NgWebElement afterDiscountValue = ngdriver.FindElement(NgBy.Model("afterDiscount"));
            string       value = afterDiscountValue.GetAttribute("value");

            Thread.Sleep(2000);

            //Assert for corect value
            Assert.AreEqual <string>("719.1", value);

            //Use if condition for custom checks
            if (value == "719.1")
            {
                //Do Nothing.
            }
            else
            {
                Assert.Fail();
            }
        }
        public void ShouldPrintOrderByFieldColumn()
        {
            GetPageContent("ng_headers_sort_example2.htm");
            String[] headers = new String[] { "First Name", "Last Name", "Age" };
            foreach (String header in headers)
            {
                for (int cnt = 0; cnt != 2; cnt++)
                {
                    IWebElement headerElement = ngDriver.FindElement(By.XPath("//th/a[contains(text(),'" + header + "')]"));
                    Console.Error.WriteLine("Clicking on header: " + header);
                    headerElement.Click();
                    // triggers ngDriver.WaitForAngular()
                    Assert.IsNotEmpty(ngDriver.Url);
                    ReadOnlyCollection <NgWebElement> ng_emps = ngDriver.FindElements(NgBy.Repeater("emp in data.employees"));
                    NgWebElement ng_emp = ng_emps[0];
                    String       field  = ng_emp.GetAttribute("ng-order-by");
                    Console.Error.WriteLine(field + ": " + ng_emp.Evaluate(field).ToString());
                    String empField = "emp." + ng_emp.Evaluate(field);
                    Console.Error.WriteLine(empField + ":");
                    var ng_emp_enumerator = ng_emps.GetEnumerator();
                    ng_emp_enumerator.Reset();
                    while (ng_emp_enumerator.MoveNext())
                    {
                        ng_emp = (NgWebElement)ng_emp_enumerator.Current;
                        if (ng_emp.Text == null)
                        {
                            break;
                        }
                        Assert.IsNotNull(ng_emp.WrappedElement);

                        // Console.Error.WriteLine(ngEmp.getAttribute("innerHTML"));
                        try
                        {
                            NgWebElement ng_column = ng_emp.FindElement(NgBy.Binding(empField));
                            Assert.IsNotNull(ng_column);
                            Console.Error.WriteLine(ng_column.Text);
                        }
                        catch (Exception ex)
                        {
                            Console.Error.WriteLine(ex.ToString());
                        }
                    }
                }
            }
        }
Exemple #15
0
        public void mobilephone(String a, String expectedresult)
        {
            IWebElement tel_field   = driver.FindElement(By.XPath(tel_xpath));
            IWebElement empty_field = driver.FindElement(By.XPath(empty));

            tel_field.Click();
            tel_field.SendKeys(a);
            empty_field.Click();
            driver.Navigate().Refresh();
            ngdriver.WaitForAngular();
            NgWebElement lastpostTime      = ngdriver.FindElement(By.CssSelector("#DeltaPlaceHolderMain > app-intry > div > app-profile-view > div.content > app-profile-feed-view > app-profile-feed > app-post:nth-child(2) > div > div > div.post__author.ng-star-inserted > div > span.link-profile__subtext"));
            NgWebElement lastPOSTcellphone = ngdriver.FindElement(By.CssSelector("#DeltaPlaceHolderMain > app-intry > div > app-profile-view > div.content > app-profile-feed-view > app-profile-feed > app-post:nth-child(2) > div > div > div.post__text.ng-star-inserted"));
            String       innertext         = lastPOSTcellphone.GetAttribute("innerHTML");
            String       outertext         = lastpostTime.GetAttribute("outerText");

            Console.WriteLine(innertext);
            Console.WriteLine(outertext);
            Assert.AreEqual(expectedresult, innertext);
        }
        public void SetExpiryDate(string workflowGUID)
        {
            string transferLicence = "Transfer Licence";

            // find the Transfer Licence link
            NgWebElement uiLicenceID = ngDriver.FindElement(By.LinkText(transferLicence));
            string       URL         = uiLicenceID.GetAttribute("href");

            // retrieve the licence ID
            string[] parsedURL = URL.Split('/');

            licenceID = parsedURL[5];

            ngDriver.IgnoreSynchronization = true;

            string result = MakeAPICall($"{baseUri}api/Licenses/{workflowGUID}/setexpiry/{licenceID}");

            Assert.Contains("OK", result);
            ClickDashboardTab(); // navigate away the back to cause data reload
            ClickLicencesTab();
        }
        public void ShouldHighlightCurrentMonthDays()
        {
            // Arrange
            try {
                wait.Until(e => e.FindElements(
                               By.ClassName("col-sm-6")).Any(element => element.Text.Contains("Embedded calendar")));
            } catch (Exception e) {
                verificationErrors.Append(e.Message);
            }
            NgWebElement ng_datepicker = ngDriver.FindElement(NgBy.Model("data.embeddedDate", "*[data-ng-app]"));

            Assert.IsNotNull(ng_datepicker);
            // NOTE: cannot highlight calendar, only individual days
            actions.MoveToElement(ng_datepicker).Build().Perform();
            ngDriver.Highlight(ng_datepicker);

            NgWebElement[] ng_dates = ng_datepicker.FindElements(NgBy.Repeater("dateObject in week.dates")).ToArray();
            Assert.IsTrue(28 <= ng_dates.Length);
            // Act
            // Highlight every day in the month
            int start = 0, end = ng_dates.Length;

            for (int cnt = 0; cnt != ng_dates.Length; cnt++)
            {
                if (start == 0 && Convert.ToInt32(ng_dates[cnt].Text) == 1)
                {
                    start = cnt;
                }
                if (cnt > start && Convert.ToInt32(ng_dates[cnt].Text) == 1)
                {
                    end = cnt;
                }
            }
            for (int cnt = start; cnt != end; cnt++)
            {
                NgWebElement ng_date = ng_dates[cnt];
                ngDriver.Highlight(ng_date, highlight_timeout, 3, (ng_date.GetAttribute("class").Contains("current")) ? "blue" : "green");
            }
        }
Exemple #18
0
 public bool IsCardViewSelected()
 {
     return(cardViewButtonElement.GetAttribute("class").Contains("active") && cardViewElement.Displayed);
 }
        public void ShouldDeposit()
        {
            ngDriver.FindElement(NgBy.ButtonText("Customer Login")).Click();
            ReadOnlyCollection <NgWebElement> ng_customers = ngDriver.FindElement(NgBy.Model("custId")).FindElements(NgBy.Repeater("cust in Customers"));

            // select customer to log in
            ng_customers.First(cust => Regex.IsMatch(cust.Text, "Harry Potter")).Click();

            ngDriver.FindElement(NgBy.ButtonText("Login")).Click();
            ngDriver.FindElement(NgBy.Options("account for account in Accounts")).Click();

            // inspect the account
            NgWebElement ng_account_number = ngDriver.FindElement(NgBy.Binding("accountNo"));
            int          account_id        = 0;

            int.TryParse(ng_account_number.Text.FindMatch(@"(?<account_number>\d+)$"), out account_id);
            Assert.AreNotEqual(0, account_id);

            int account_balance = -1;

            int.TryParse(ngDriver.FindElement(NgBy.Binding("amount")).Text.FindMatch(@"(?<account_balance>\d+)$"), out account_balance);
            Assert.AreNotEqual(-1, account_balance);
            NgWebElement ng_deposit_button = ngDriver.FindElement(NgBy.PartialButtonText("Deposit"));

            Assert.IsTrue(ng_deposit_button.Displayed);

            actions.MoveToElement(ng_deposit_button.WrappedElement).Build().Perform();
            Thread.Sleep(500);
            ng_deposit_button.Click();

            // core Selenium
            wait.Until(ExpectedConditions.ElementExists(By.CssSelector("form[name='myForm']")));
            NgWebElement ng_form_element = new NgWebElement(ngDriver, driver.FindElement(By.CssSelector("form[name='myForm']")));

            // deposit amount
            NgWebElement ng_deposit_amount = ng_form_element.FindElement(NgBy.Model("amount"));

            ng_deposit_amount.SendKeys("100");

            // wait.Until(ExpectedConditions.ElementIsVisible(NgBy.ButtonText("Deposit")));

            // Confirm to perform deposit
            ReadOnlyCollection <NgWebElement> ng_deposit_buttons = ng_form_element.FindElements(NgBy.ButtonText("Deposit"));
            NgWebElement ng_submit_deposit_button = ng_form_element.FindElements(NgBy.ButtonText("Deposit")).First(o => o.GetAttribute("class").IndexOf("btn-default", StringComparison.InvariantCultureIgnoreCase) > -1);
            String       x = ng_submit_deposit_button.GetAttribute("class");

            actions.MoveToElement(ng_submit_deposit_button.WrappedElement).Build().Perform();
            ngDriver.Highlight(ng_submit_deposit_button, highlight_timeout);

            ng_submit_deposit_button.Click();
            // http://www.way2automation.com/angularjs-protractor/banking/depositTx.html

            // inspect message
            var ng_message = ngDriver.FindElement(NgBy.Binding("message"));

            StringAssert.Contains("Deposit Successful", ng_message.Text);
            ngDriver.Highlight(ng_message, highlight_timeout);

            // re-read the amount
            int updated_account_balance = -1;

            int.TryParse(ngDriver.FindElement(NgBy.Binding("amount")).Text.FindMatch(@"(?<account_balance>\d+)$"), out updated_account_balance);
            Assert.AreEqual(updated_account_balance, account_balance + 100);
        }
        public void SavedEventHistoryIsCorrect()
        {
            /*
             * Page Title: Catered Event Authorization Request
             */

            // create event authorization data
            string eventContactName  = "AutoTestEventContactName";
            string eventContactPhone = "(250) 000-0000";

            string eventDescription       = "Automated test event description added here.";
            string eventClientOrHostName  = "Automated test event";
            string maximumAttendance      = "100";
            string maximumStaffAttendance = "25";

            string venueNameDescription      = "Automated test venue name or description";
            string venueAdditionalInfo       = "Automated test additional venue information added here.";
            string physicalAddStreetAddress1 = "Automated test street address 1";
            string physicalAddStreetAddress2 = "Automated test street address 2";
            string physicalAddCity           = "Victoria";
            string physicalAddPostalCode     = "V9A 6X5";

            // check event contact name
            NgWebElement uiEventContactName = ngDriver.FindElement(By.CssSelector("input[formcontrolname='contactName']"));

            Assert.True(uiEventContactName.GetAttribute("value") == eventContactName);

            // check event contact phone
            NgWebElement uiEventContactPhone = ngDriver.FindElement(By.CssSelector("input[formcontrolname='contactPhone']"));

            Assert.True(uiEventContactPhone.GetAttribute("value") == eventContactPhone);

            // check corporate event type selected
            NgWebElement uiEventType = ngDriver.FindElement(By.CssSelector("[formcontrolname='eventType']"));

            Assert.True(uiEventType.GetAttribute("value") == "2: 845280002");

            // check event description
            NgWebElement uiEventDescription = ngDriver.FindElement(By.CssSelector("textarea[formcontrolname='eventTypeDescription']"));

            Assert.True(uiEventDescription.GetAttribute("value") == eventDescription);

            // check event client or host name
            NgWebElement uiEventClientOrHostName = ngDriver.FindElement(By.CssSelector("input[formcontrolname='clientHostname']"));

            Assert.True(uiEventClientOrHostName.GetAttribute("value") == eventClientOrHostName);

            // check maximum attendance
            NgWebElement uiMaxAttendance = ngDriver.FindElement(By.CssSelector("input[formcontrolname='maxAttendance']"));

            Assert.True(uiMaxAttendance.GetAttribute("value") == maximumAttendance);

            // check maximum staff attendance
            NgWebElement uiMaxStaffAttendance = ngDriver.FindElement(By.CssSelector("input[formcontrolname='maxStaffAttendance']"));

            Assert.True(uiMaxStaffAttendance.GetAttribute("value") == maximumStaffAttendance);

            // check whether minors are attending - yes
            NgWebElement uiMinorsAttending = ngDriver.FindElement(By.CssSelector("[formcontrolname='minorsAttending']"));

            Assert.True(uiMinorsAttending.GetAttribute("value") == "true");

            // check type of food service provided
            NgWebElement uiFoodServiceProvided = ngDriver.FindElement(By.CssSelector("[formcontrolname='foodService']"));

            Assert.True(uiFoodServiceProvided.GetAttribute("value") == "0: 845280000");

            // check type of entertainment provided
            NgWebElement uiEntertainmentProvided = ngDriver.FindElement(By.CssSelector("[formcontrolname='entertainment']"));

            Assert.True(uiEntertainmentProvided.GetAttribute("value") == "1: 845280001");

            // check venue name description
            NgWebElement uiVenueNameDescription = ngDriver.FindElement(By.CssSelector("textarea[formcontrolname='venueDescription']"));

            Assert.True(uiVenueNameDescription.GetAttribute("value") == venueNameDescription);

            // check venue location - indoors
            NgWebElement uiVenueLocation = ngDriver.FindElement(By.CssSelector("[formcontrolname='specificLocation']"));

            Assert.True(uiVenueLocation.GetAttribute("value") == "0: 845280000");

            // check venue additional info
            NgWebElement uiVenueAdditionalInfo = ngDriver.FindElement(By.CssSelector("textarea[formcontrolname='additionalLocationInformation']"));

            Assert.True(uiVenueAdditionalInfo.GetAttribute("value") == venueAdditionalInfo);

            // check physical address - street address 1
            NgWebElement uiPhysicalAddStreetAddress1 = ngDriver.FindElement(By.CssSelector("input[formcontrolname='street1']"));

            Assert.True(uiPhysicalAddStreetAddress1.GetAttribute("value") == physicalAddStreetAddress1);

            // check physical address - street address 2
            NgWebElement uiPhysicalAddStreetAddress2 = ngDriver.FindElement(By.CssSelector("input[formcontrolname='street2']"));

            Assert.True(uiPhysicalAddStreetAddress2.GetAttribute("value") == physicalAddStreetAddress2);

            // check physical address - city
            NgWebElement uiPhysicalAddCity = ngDriver.FindElement(By.CssSelector("input[formcontrolname='city']"));

            Assert.True(uiPhysicalAddCity.GetAttribute("value") == physicalAddCity);

            // check physical address - postal code
            NgWebElement uiPhysicalAddPostalCode = ngDriver.FindElement(By.CssSelector("input[formcontrolname='postalCode']"));

            Assert.True(uiPhysicalAddPostalCode.GetAttribute("value") == physicalAddPostalCode);

            // check event start and end times
            NgWebElement uiEventStartTimeHours = ngDriver.FindElement(By.CssSelector("[formcontrolname='startTime'] input[aria-label='Hours']"));

            Assert.True(uiEventStartTimeHours.GetAttribute("value") == "09");

            NgWebElement uiEventStartTimeMinutes = ngDriver.FindElement(By.CssSelector("[formcontrolname='startTime'] input[aria-label='Minutes']"));

            Assert.True(uiEventStartTimeMinutes.GetAttribute("value") == "00");

            NgWebElement uiEventCloseTimeHours = ngDriver.FindElement(By.CssSelector("[formcontrolname='endTime'] input[aria-label='Hours']"));

            Assert.True(uiEventCloseTimeHours.GetAttribute("value") == "02");

            NgWebElement uiEventCloseTimeMinutes = ngDriver.FindElement(By.CssSelector("[formcontrolname='endTime'] input[aria-label='Minutes']"));

            Assert.True(uiEventCloseTimeMinutes.GetAttribute("value") == "00");

            // check liquor start and end times
            NgWebElement uiLiquorStartTimeHours = ngDriver.FindElement(By.CssSelector("[formcontrolname='liquorStartTime'] input[aria-label='Hours']"));

            Assert.True(uiLiquorStartTimeHours.GetAttribute("value") == "09");

            NgWebElement uiLiquorStartTimeMinutes = ngDriver.FindElement(By.CssSelector("[formcontrolname='liquorStartTime'] input[aria-label='Minutes']"));

            Assert.True(uiLiquorStartTimeMinutes.GetAttribute("value") == "00");

            NgWebElement uiLiquorCloseTimeHours = ngDriver.FindElement(By.CssSelector("[formcontrolname='liquorEndTime'] input[aria-label='Hours']"));

            Assert.True(uiLiquorCloseTimeHours.GetAttribute("value") == "02");

            NgWebElement uiLiquorCloseTimeMinutes = ngDriver.FindElement(By.CssSelector("[formcontrolname='endTime'] input[aria-label='Minutes']"));

            Assert.True(uiLiquorCloseTimeMinutes.GetAttribute("value") == "00");
        }
        public void ShouldDirectSelect()
        {
            // Arrange
            try {
                wait.Until(e => e.FindElements(
                               By.ClassName("col-sm-6")).Any(element => element.Text.IndexOf("Drop-down Datetime with input box", StringComparison.InvariantCultureIgnoreCase) > -1));
            } catch (Exception e) {
                verificationErrors.Append(e.Message);
            }
            NgWebElement ng_datepicker = ngDriver.FindElement(NgBy.Model("data.dateDropDownInput", "*[data-ng-app]"));

            Assert.IsNotNull(ng_datepicker);
            // ng_datepicker.Clear();
            ngDriver.Highlight(ng_datepicker);
            IWebElement calendar = ngDriver.FindElement(By.CssSelector(".input-group-addon"));

            Assert.IsNotNull(calendar);
            ngDriver.Highlight(calendar);
            Actions actions = new Actions(ngDriver.WrappedDriver);

            actions.MoveToElement(calendar).Click().Build().Perform();

            IWebElement  dropdown    = driver.FindElement(By.CssSelector("div.dropdown.open ul.dropdown-menu"));
            NgWebElement ng_dropdown = new NgWebElement(ngDriver, dropdown);

            Assert.IsNotNull(ng_dropdown);
            ReadOnlyCollection <NgWebElement> elements = ng_dropdown.FindElements(NgBy.Repeater("dateObject in week.dates"));

            Assert.IsTrue(28 <= elements.Count);

            String      monthDate   = "12";
            IWebElement dateElement = ng_dropdown.FindElements(NgBy.CssContainingText("td.ng-binding", monthDate)).First();

            Console.Error.WriteLine("Mondh Date: " + dateElement.Text);
            dateElement.Click();
            NgWebElement ng_element = ng_dropdown.FindElement(NgBy.Model("data.dateDropDownInput", "[data-ng-app]"));

            Assert.IsNotNull(ng_element);
            ngDriver.Highlight(ng_element);
            ReadOnlyCollection <NgWebElement> ng_dataDates = ng_element.FindElements(NgBy.Repeater("dateObject in data.dates"));

            Assert.AreEqual(24, ng_dataDates.Count);

            String       timeOfDay = "6:00 PM";
            NgWebElement ng_hour   = ng_element.FindElements(NgBy.CssContainingText("span.hour", timeOfDay)).First();

            Assert.IsNotNull(ng_hour);
            ngDriver.Highlight(ng_hour);
            Console.Error.WriteLine("Hour of the day: " + ng_hour.Text);
            ng_hour.Click();
            String specificMinute = "6:35 PM";

            // no need to reload
            ng_element = ng_dropdown.FindElement(NgBy.Model("data.dateDropDownInput", "*[data-ng-app]"));
            Assert.IsNotNull(ng_element);
            ngDriver.Highlight(ng_element);
            NgWebElement ng_minute = ng_element.FindElements(NgBy.CssContainingText("span.minute", specificMinute)).First();

            Assert.IsNotNull(ng_minute);
            ngDriver.Highlight(ng_minute);
            Console.Error.WriteLine("Time of the day: " + ng_minute.Text);
            ng_minute.Click();
            ng_datepicker = ngDriver.FindElement(NgBy.Model("data.dateDropDownInput", "[data-ng-app]"));
            ngDriver.Highlight(ng_datepicker, 100);
            Console.Error.WriteLine("Selected Date/time: " + ng_datepicker.GetAttribute("value"));
        }
        public void AccountProfileData(string bizType)
        {
            // check legal name field is populated
            NgWebElement uiLegalName         = ngDriver.FindElement(By.CssSelector("div:nth-of-type(2) > div:nth-of-type(1) > div > div > div:nth-of-type(1) > app-field:nth-of-type(1) > section > div > section > input"));
            string       fieldValueLegalName = uiLegalName.GetAttribute("value");

            Assert.True(fieldValueLegalName != null);

            // check business number is correct
            NgWebElement uiBusinessNumber = ngDriver.FindElement(By.CssSelector("input[formcontrolname='businessNumber']"));

            Assert.True(uiBusinessNumber.GetAttribute("value") == "123456789");

            // check business type has been selected correctly
            if (bizType != "n indigenous nation account profile")
            {
                NgWebElement uiBusinessType = ngDriver.FindElement(By.CssSelector("select.form-control"));

                if (bizType == " private corporation")
                {
                    Assert.True(uiBusinessType.GetAttribute("value") == "Private Corporation");
                }

                if (bizType == " public corporation")
                {
                    Assert.True(uiBusinessType.GetAttribute("value") == "Public Corporation");
                }

                if (bizType == " sole proprietorship")
                {
                    Assert.True(uiBusinessType.GetAttribute("value") == "Sole Proprietor");
                }

                if (bizType == " partnership")
                {
                    Assert.True(uiBusinessType.GetAttribute("value") == "Partnership");
                }

                if (bizType == " society")
                {
                    Assert.True(uiBusinessType.GetAttribute("value") == "Society");
                }

                if (bizType == " university")
                {
                    Assert.True(uiBusinessType.GetAttribute("value") == "University");
                }

                if (bizType == " local government")
                {
                    Assert.True(uiBusinessType.GetAttribute("value") == "Local Government");
                }
            }

            // check incorporation number and date of incorporation are correct
            if (bizType == " private corporation" || bizType == " society" || bizType == " public corporation")
            {
                NgWebElement uiIncorporationNumber = ngDriver.FindElement(By.CssSelector("input[formcontrolname='bcIncorporationNumber']"));
                Assert.True(uiIncorporationNumber.GetAttribute("value") == "BC1234567");

                NgWebElement uiIncorporationDate         = ngDriver.FindElement(By.CssSelector("input[formcontrolname='bcIncorporationNumber']"));
                string       fieldValueIncorporationDate = uiIncorporationDate.GetAttribute("value");
                Assert.True(fieldValueIncorporationDate != null);
            }

            // check street address 1 is correct
            NgWebElement uiPhysicalAddressStreet = ngDriver.FindElement(By.CssSelector("input[formcontrolname='physicalAddressStreet']"));

            Assert.True(uiPhysicalAddressStreet.GetAttribute("value") == "645 Tyee Road");

            // check street address 2 is correct
            NgWebElement uiPhysicalAddressStreet2 = ngDriver.FindElement(By.CssSelector("input[formcontrolname='physicalAddressStreet2']"));

            Assert.True(uiPhysicalAddressStreet2.GetAttribute("value") == "West");

            // check physical address city is correct
            NgWebElement uiPhysicalAddressCity = ngDriver.FindElement(By.CssSelector("input[formcontrolname='physicalAddressCity']"));

            Assert.True(uiPhysicalAddressCity.GetAttribute("value") == "Victoria");

            // check physical address province is correct
            NgWebElement uiPhysicalAddressProvince = ngDriver.FindElement(By.CssSelector("input[formcontrolname='physicalAddressProvince']"));

            Assert.True(uiPhysicalAddressProvince.GetAttribute("value") == "British Columbia");

            // check physical address postal code is correct
            NgWebElement uiPhysicalAddressPostalCode = ngDriver.FindElement(By.CssSelector("input[formcontrolname='physicalAddressPostalCode']"));

            Assert.True(uiPhysicalAddressPostalCode.GetAttribute("value") == "V9A6X5");

            // check physical address country is correct
            NgWebElement uiPhysicalAddressCountry = ngDriver.FindElement(By.CssSelector("input[formcontrolname='physicalAddressCountry']"));

            Assert.True(uiPhysicalAddressCountry.GetAttribute("value") == "Canada");

            // check mailing address street 1 is correct
            NgWebElement uiMailingAddressStreet = ngDriver.FindElement(By.CssSelector("input[formcontrolname='mailingAddressStreet']"));

            Assert.True(uiMailingAddressStreet.GetAttribute("value") == "#22");

            // check mailing address street 2 is correct
            NgWebElement uiMailingAddressStreet2 = ngDriver.FindElement(By.CssSelector("input[formcontrolname='mailingAddressStreet2']"));

            Assert.True(uiMailingAddressStreet2.GetAttribute("value") == "700 Bellevue Way NE");

            // check mailing address city is correct
            NgWebElement uiMailingAddressCity = ngDriver.FindElement(By.CssSelector("input[formcontrolname='mailingAddressCity']"));

            Assert.True(uiMailingAddressCity.GetAttribute("value") == "Bellevue");

            // check mailing address province/state is correct
            NgWebElement uiMailingAddressProvince = ngDriver.FindElement(By.CssSelector("input[formcontrolname='mailingAddressProvince']"));

            Assert.True(uiMailingAddressProvince.GetAttribute("value") == "WA");

            // check mailing address postal/zip is correct
            NgWebElement uiMailingAddressPostalCode = ngDriver.FindElement(By.CssSelector("input[formcontrolname='mailingAddressPostalCode']"));

            Assert.True(uiMailingAddressPostalCode.GetAttribute("value") == "98004");

            // check mailing address country is correct
            NgWebElement uiMailingAddressCountry = ngDriver.FindElement(By.CssSelector("input[formcontrolname='mailingAddressCountry']"));

            Assert.True(uiMailingAddressCountry.GetAttribute("value") == "United States");

            // check contact phone is correct
            NgWebElement uiContactPhone = ngDriver.FindElement(By.CssSelector("input[formcontrolname='contactPhone']"));

            Assert.True(uiContactPhone.GetAttribute("value") == "(250) 181-1818");

            // check contact email is correct
            NgWebElement uiContactEmail = ngDriver.FindElement(By.CssSelector("input[formcontrolname='contactEmail']"));

            Assert.True(uiContactEmail.GetAttribute("value") == "*****@*****.**");

            // check liquor policy information link is correct
            if ((bizType == "n indigenous nation account profile") || (bizType == " local government account profile"))
            {
                NgWebElement uiWebsiteUrl = ngDriver.FindElement(By.CssSelector("input[formcontrolname='websiteUrl']"));
                Assert.True(uiWebsiteUrl.GetAttribute("value") == "https://www.liquorpolicy.org");
            }

            // check authorized person first name is populated
            NgWebElement uiFirstName         = ngDriver.FindElement(By.CssSelector("input[formcontrolname='firstname']"));
            string       fieldValueFirstName = uiFirstName.GetAttribute("value");

            Assert.True(fieldValueFirstName != null);

            // check authorized person last name is populated
            NgWebElement uiLastName         = ngDriver.FindElement(By.CssSelector("input[formcontrolname='lastname']"));
            string       fieldValueLastName = uiLastName.GetAttribute("value");

            Assert.True(fieldValueLastName != null);

            // check authorized person title/position is correct
            NgWebElement uiJobTitle = ngDriver.FindElement(By.CssSelector("input[formcontrolname='jobTitle']"));

            Assert.True(uiJobTitle.GetAttribute("value") == "CEO");

            // check authorized person phone number is correct
            NgWebElement uiTelephone1 = ngDriver.FindElement(By.CssSelector("input[formcontrolname='telephone1']"));

            Assert.True(uiTelephone1.GetAttribute("value") == "(778) 181-1818");

            // check authorized person email address is correct
            NgWebElement uiEmailAddress1 = ngDriver.FindElement(By.CssSelector("input[formcontrolname='emailaddress1']"));

            Assert.True(uiEmailAddress1.GetAttribute("value") == "*****@*****.**");

            // check indigenous nation connection details are correct
            if ((bizType == "n indigenous nation account profile") || (bizType == " local government account profile"))
            {
                NgWebElement uiINConnectionToFederalProducerDetails = ngDriver.FindElement(By.CssSelector("textarea[formcontrolname='iNConnectionToFederalProducerDetails']"));
                Assert.True(uiINConnectionToFederalProducerDetails.GetAttribute("value") == "Name and details of federal producer (automated test) for IN/local government.");
            }

            // check partnership connection details are correct
            if (bizType == " partnership")
            {
                NgWebElement uiDetailsFederalProducer2 = ngDriver.FindElement(By.CssSelector("textarea[formcontrolname='partnersConnectionFederalProducerDetails']"));
                Assert.True(uiDetailsFederalProducer2.GetAttribute("value") == "The name of the federal producer and details of the connection (partnership).");
            }

            // check federal producer connection to corporation details are correct
            if ((bizType == " partnership") || (bizType == " private corporation") || (bizType == " sole proprietorship") || (bizType == " university"))
            {
                NgWebElement uiDetailsFederalProducer3 = ngDriver.FindElement(By.CssSelector("textarea[formcontrolname='federalProducerConnectionToCorpDetails']"));
                Assert.True(uiDetailsFederalProducer3.GetAttribute("value") == "Name and details of federal producer connection to corporation.");
            }

            // check corporation connection to federal producer details are correct
            if ((bizType == " private corporation") || (bizType == " public corporation") || (bizType == " sole proprietorship") || (bizType == " university"))
            {
                NgWebElement uiDetailsFederalProducer2 = ngDriver.FindElement(By.CssSelector("textarea[formcontrolname='corpConnectionFederalProducerDetails']"));
                Assert.True(uiDetailsFederalProducer2.GetAttribute("value") == "The name of the federal producer and details of the connection.");
            }

            // check public corporation shareholder and family relationship details are correct
            if (bizType == " public corporation")
            {
                NgWebElement uiShareholderDetails = ngDriver.FindElement(By.CssSelector("textarea[formcontrolname='share20PlusConnectionProducerDetails']"));
                Assert.True(uiShareholderDetails.GetAttribute("value") == "Details of shareholder relationship.");

                NgWebElement uiFamilyConnectionDetails = ngDriver.FindElement(By.CssSelector("textarea[formcontrolname='share20PlusFamilyConnectionProducerDetail']"));
                Assert.True(uiFamilyConnectionDetails.GetAttribute("value") == "Details of family relationship (automated test).");
            }

            // check society federal producer details are correct
            if (bizType == " society")
            {
                NgWebElement uiSocietyConnectionDetails = ngDriver.FindElement(By.CssSelector("textarea[formcontrolname='societyConnectionFederalProducerDetails']"));
                Assert.True(uiSocietyConnectionDetails.GetAttribute("value") == "Details of society/federal producer relationship.");
            }

            // check financial interest details are correct
            NgWebElement uiLiquorFinancialInterestDetails = ngDriver.FindElement(By.CssSelector("textarea[formcontrolname='liquorFinancialInterestDetails']"));

            Assert.True(uiLiquorFinancialInterestDetails.GetAttribute("value") == "Details of the financial interest (automated test).");
        }
Exemple #23
0
        public void ShouldDirectSelectFromDatePicker()
        {
            Common.GetLocalHostPageContent("ng_datepicker.htm");
            // http://dalelotts.github.io/angular-bootstrap-datetimepicker/
            NgWebElement ng_result = ngDriver.FindElement(NgBy.Model("data.inputOnTimeSet"));

            ng_result.Clear();
            ngDriver.Highlight(ng_result);
            IWebElement calendar = ngDriver.FindElement(By.CssSelector(".input-group-addon"));

            ngDriver.Highlight(calendar);
            Actions actions = new Actions(ngDriver.WrappedDriver);

            actions.MoveToElement(calendar).Click().Build().Perform();

            int datepicker_width = 900;
            int datepicker_heght = 800;

            driver.Manage().Window.Size = new System.Drawing.Size(datepicker_width, datepicker_heght);
            IWebElement  dropdown    = driver.FindElement(By.CssSelector("div.dropdown.open ul.dropdown-menu"));
            NgWebElement ng_dropdown = new NgWebElement(ngDriver, dropdown);

            Assert.IsNotNull(ng_dropdown);
            ReadOnlyCollection <NgWebElement> elements = ng_dropdown.FindElements(NgBy.Repeater("dateObject in week.dates"));

            Assert.IsTrue(28 <= elements.Count);

            String      monthDate   = "12";
            IWebElement dateElement = ng_dropdown.FindElements(NgBy.CssContainingText("td.ng-binding", monthDate)).First();

            Console.Error.WriteLine("Mondh Date: " + dateElement.Text);
            dateElement.Click();
            NgWebElement ng_element = ng_dropdown.FindElement(NgBy.Model("data.inputOnTimeSet"));

            Assert.IsNotNull(ng_element);
            ngDriver.Highlight(ng_element);
            ReadOnlyCollection <NgWebElement> ng_dataDates = ng_element.FindElements(NgBy.Repeater("dateObject in data.dates"));

            Assert.AreEqual(24, ng_dataDates.Count);

            String       timeOfDay = "6:00 PM";
            NgWebElement ng_hour   = ng_element.FindElements(NgBy.CssContainingText("span.hour", timeOfDay)).First();

            Assert.IsNotNull(ng_hour);
            ngDriver.Highlight(ng_hour);
            Console.Error.WriteLine("Hour of the day: " + ng_hour.Text);
            ng_hour.Click();
            String specificMinute = "6:35 PM";

            // reload
            // dropdown = driver.FindElement(By.CssSelector("div.dropdown.open ul.dropdown-menu"));
            // ng_dropdown = new NgWebElement(ngDriver, dropdown);
            ng_element = ng_dropdown.FindElement(NgBy.Model("data.inputOnTimeSet"));
            Assert.IsNotNull(ng_element);
            ngDriver.Highlight(ng_element);
            NgWebElement ng_minute = ng_element.FindElements(NgBy.CssContainingText("span.minute", specificMinute)).First();

            Assert.IsNotNull(ng_minute);
            ngDriver.Highlight(ng_minute);
            Console.Error.WriteLine("Time of the day: " + ng_minute.Text);
            ng_minute.Click();
            ng_result = ngDriver.FindElement(NgBy.Model("data.inputOnTimeSet"));
            ngDriver.Highlight(ng_result, 100);
            Console.Error.WriteLine("Selected Date/time: " + ng_result.GetAttribute("value"));
        }
        public void ShouldSelectOneByOne()
        {
            // Given multuselect directive
            NgWebElement ng_directive = ngDriver.FindElement(NgBy.Model("selectedCar"));

            Assert.IsNotNull(ng_directive.WrappedElement);
            Assert.That(ng_directive.TagName, Is.EqualTo("am-multiselect"));

            // open am-multiselect
            IWebElement toggleSelect = ng_directive.FindElement(By.CssSelector("button[ng-click='toggleSelect()']"));

            Assert.IsNotNull(toggleSelect);
            Assert.IsTrue(toggleSelect.Displayed);
            toggleSelect.Click();

            // When I want to select every "Audi", "Honda" or "Toyota" car
            String makeMatcher = "(?i:" + String.Join("|", new String[] {
                "audi",
                "honda",
                "toyota"
            }) + ")";
            ReadOnlyCollection <NgWebElement> cars = ng_directive.FindElements(NgBy.Repeater("i in items"));

            Assert.Greater(cars.Count(car => Regex.IsMatch(car.Text, makeMatcher)), 0);
            // And I pick every matching car one item at a time
            int selected_cars_count = 0;

            for (int num_row = 0; num_row < cars.Count(); num_row++)
            {
                NgWebElement ng_item = ng_directive.FindElement(NgBy.Repeaterelement("i in items", num_row, "i.label"));

                if (Regex.IsMatch(ng_item.Text, makeMatcher, RegexOptions.IgnoreCase))
                {
                    Console.Error.WriteLine("Selecting: " + ng_item.Text);
                    ng_item.Click();
                    selected_cars_count++;
                    ngDriver.Highlight(ng_item, highlight_timeout);
                }
            }
            // Then button text shows the total number of cars I have selected
            IWebElement button = driver.FindElement(By.CssSelector("am-multiselect > div > button"));

            ngDriver.Highlight(button, highlight_timeout);
            StringAssert.IsMatch(@"There are (\d+) car\(s\) selected", button.Text);
            int displayed_count = 0;

            int.TryParse(button.Text.FindMatch(@"(?<count>\d+)"), out displayed_count);

            Assert.AreEqual(displayed_count, selected_cars_count);
            Console.Error.WriteLine("Button text: " + button.Text);

            try {
                // NOTE: the following does not work:
                // ms-selected = "There are {{selectedCar.length}}
                NgWebElement ng_button = new NgWebElement(ngDriver, button);
                Console.Error.WriteLine(ng_button.GetAttribute("innerHTML"));
                NgWebElement ng_length = ng_button.FindElement(NgBy.Binding("selectedCar.length"));
                ng_length = ngDriver.FindElement(NgBy.Binding("selectedCar.length"));
                Console.Error.WriteLine(ng_length.Text);
            } catch (NullReferenceException) {
            }
        }
        public void SavedEventHistoryIsCorrect()
        {
            /*
             * Page Title: Catered Event Authorization Request
             */

            // create event authorization data
            string eventContactName  = "AutoTestEventContactName";
            string eventContactPhone = "(250) 000-0000";

            string eventDescription       = "Automated test event description added here.";
            string eventClientOrHostName  = "Automated test event";
            string maximumAttendance      = "100";
            string maximumStaffAttendance = "25";

            string venueNameDescription      = "Automated test venue name or description";
            string venueAdditionalInfo       = "Automated test additional venue information added here.";
            string physicalAddStreetAddress1 = "Automated test street address 1";
            string physicalAddStreetAddress2 = "Automated test street address 2";
            string physicalAddCity           = "Victoria";
            string physicalAddPostalCode     = "V9A 6X5";

            // check event contact name
            NgWebElement uiEventContactName = ngDriver.FindElement(By.CssSelector("input[formcontrolname='contactName']"));

            Assert.True(uiEventContactName.GetAttribute("value") == eventContactName);

            // check event contact phone
            NgWebElement uiEventContactPhone = ngDriver.FindElement(By.CssSelector("input[formcontrolname='contactPhone']"));

            Assert.True(uiEventContactPhone.GetAttribute("value") == eventContactPhone);

            // check community event type selected - TODO
            NgWebElement uiEventType = ngDriver.FindElement(By.CssSelector("[formcontrolname='eventType'] [value='1: 845280001']"));

            // check event description
            NgWebElement uiEventDescription = ngDriver.FindElement(By.CssSelector("textarea[formcontrolname='eventTypeDescription']"));

            Assert.True(uiEventDescription.GetAttribute("value") == eventDescription);

            // check event client or host name
            NgWebElement uiEventClientOrHostName = ngDriver.FindElement(By.CssSelector("input[formcontrolname='clientHostname']"));

            Assert.True(uiEventClientOrHostName.GetAttribute("value") == eventClientOrHostName);

            // check maximum attendance
            NgWebElement uiMaxAttendance = ngDriver.FindElement(By.CssSelector("input[formcontrolname='maxAttendance']"));

            Assert.True(uiMaxAttendance.GetAttribute("value") == maximumAttendance);

            // check maximum staff attendance
            NgWebElement uiMaxStaffAttendance = ngDriver.FindElement(By.CssSelector("input[formcontrolname='maxStaffAttendance']"));

            Assert.True(uiMaxStaffAttendance.GetAttribute("value") == maximumStaffAttendance);

            // check whether minors are attending - yes
            NgWebElement uiMinorsAttending = ngDriver.FindElement(By.CssSelector("[formcontrolname='minorsAttending'] option[value='true']"));

            Assert.True(uiMinorsAttending.Selected);

            // check type of food service provided - TODO
            NgWebElement uiFoodServiceProvided = ngDriver.FindElement(By.CssSelector("[formcontrolname='foodService'] option[value='0: 845280000']"));

            // check type of entertainment provided - TODO
            NgWebElement uiEntertainmentProvided = ngDriver.FindElement(By.CssSelector("[formcontrolname='entertainment'] option[value='1: 845280001']"));

            // check venue name description
            NgWebElement uiVenueNameDescription = ngDriver.FindElement(By.CssSelector("textarea[formcontrolname='venueDescription']"));

            Assert.True(uiVenueNameDescription.GetAttribute("value") == venueNameDescription);

            // check venue location - TODO
            NgWebElement uiVenueLocation = ngDriver.FindElement(By.CssSelector("[formcontrolname='specificLocation'] option[value='1: 845280001']"));

            // check venue additional info
            NgWebElement uiVenueAdditionalInfo = ngDriver.FindElement(By.CssSelector("textarea[formcontrolname='additionalLocationInformation']"));

            Assert.True(uiVenueAdditionalInfo.GetAttribute("value") == venueAdditionalInfo);

            // check physical address - street address 1
            NgWebElement uiPhysicalAddStreetAddress1 = ngDriver.FindElement(By.CssSelector("input[formcontrolname='street1']"));

            Assert.True(uiPhysicalAddStreetAddress1.GetAttribute("value") == physicalAddStreetAddress1);

            // check physical address - street address 2
            NgWebElement uiPhysicalAddStreetAddress2 = ngDriver.FindElement(By.CssSelector("input[formcontrolname='street2']"));

            Assert.True(uiPhysicalAddStreetAddress2.GetAttribute("value") == physicalAddStreetAddress2);

            // check physical address - city
            NgWebElement uiPhysicalAddCity = ngDriver.FindElement(By.CssSelector("input[formcontrolname='city']"));

            Assert.True(uiPhysicalAddCity.GetAttribute("value") == physicalAddCity);

            // check physical address - postal code
            NgWebElement uiPhysicalAddPostalCode = ngDriver.FindElement(By.CssSelector("input[formcontrolname='postalCode']"));

            Assert.True(uiPhysicalAddPostalCode.GetAttribute("value") == physicalAddPostalCode);

            // check start date is selected - TODO
            NgWebElement uiVenueStartDate1 = ngDriver.FindElement(By.CssSelector("input[formcontrolname='startDate']"));

            // check end date is selected - TODO
            NgWebElement uiVenueEndDate1 = ngDriver.FindElement(By.CssSelector("input[formcontrolname='endDate']"));

            // check event end time after 2am - TODO
            NgWebElement uiEventCloseTime = ngDriver.FindElement(By.CssSelector(".col-md-2:nth-child(3) .ngb-tp-minute .ng-star-inserted:nth-child(1) .ngb-tp-chevron"));

            // check liquor end time after 2am - TODO
            NgWebElement uiLiquorCloseTime = ngDriver.FindElement(By.CssSelector(".col-md-2:nth-child(5) .ngb-tp-minute .btn-link:nth-child(1) .ngb-tp-chevron"));
        }
Exemple #26
0
 /// <summary>
 /// Is email field showing a warning
 /// </summary>
 /// <returns>True if CSS style is invalid</returns>
 public bool IsEmailFieldWarning()
 {
     return(emailField.GetAttribute("class").Contains("invalid"));
 }
Exemple #27
0
        public void ShouldLoginCustomer()
        {
            NgWebElement ng_customer_button = ngDriver.FindElement(NgBy.ButtonText("Customer Login"));

            StringAssert.IsMatch("Customer Login", ng_customer_button.Text);
            ngDriver.Highlight(ng_customer_button, highlight_timeout);
            // core Selenium
            IWebElement customer_button = driver.FindElement(By.XPath("//button[contains(.,'Customer Login')]"));

            StringAssert.IsMatch("Customer Login", customer_button.Text);
            ngDriver.Highlight(customer_button, highlight_timeout);

            ng_customer_button.Click();

                        #pragma warning disable 618
            NgWebElement ng_customer_select = ngDriver.FindElement(NgBy.Input("custId"));
                        #pragma warning restore 618

            StringAssert.IsMatch("userSelect", ng_customer_select.GetAttribute("id"));
            ReadOnlyCollection <NgWebElement> ng_customers = ng_customer_select.FindElements(NgBy.Repeater("cust in Customers"));
            Assert.AreNotEqual(0, ng_customers.Count);
            // won't move to or highlight select options
            foreach (NgWebElement ng_customer in ng_customers)
            {
                actions.MoveToElement(ng_customer);
                ngDriver.Highlight(ng_customer);
            }
            // pick first customer
            NgWebElement first_customer = ng_customers.First();
            Assert.IsTrue(first_customer.Displayed);

            // the {{user}} is composed from first and last name
            StringAssert.IsMatch("(?:[^ ]+) +(?:[^ ]+)", first_customer.Text);
            string user = first_customer.Text;
            first_customer.Click();

            // login button
            NgWebElement ng_login_button = ngDriver.FindElement(NgBy.ButtonText("Login"));
            Assert.IsTrue(ng_login_button.Displayed && ng_login_button.Enabled);
            ngDriver.Highlight(ng_login_button, highlight_timeout);
            ng_login_button.Click();

            NgWebElement ng_greeting = ngDriver.FindElement(NgBy.Binding("user"));
            Assert.IsNotNull(ng_greeting);
            StringAssert.IsMatch(user, ng_greeting.Text);
            ngDriver.Highlight(ng_greeting, highlight_timeout);

            NgWebElement ng_account_number = ngDriver.FindElement(NgBy.Binding("accountNo"));
            Assert.IsNotNull(ng_account_number);
            theReg = new Regex(@"(?<account_id>\d+)$");
            Assert.IsTrue(theReg.IsMatch(ng_account_number.Text));
            ngDriver.Highlight(ng_account_number, highlight_timeout);

            NgWebElement ng_account_balance = ngDriver.FindElement(NgBy.Binding("amount"));
            Assert.IsNotNull(ng_account_balance);
            theReg = new Regex(@"(?<account_balance>\d+)$");
            Assert.IsTrue(theReg.IsMatch(ng_account_balance.Text));
            ngDriver.Highlight(ng_account_balance, highlight_timeout);

            NgWebElement ng_account_currency = ngDriver.FindElement(NgBy.Binding("currency"));
            Assert.IsNotNull(ng_account_currency);
            theReg = new Regex(@"(?<account_currency>(?:Dollar|Pound|Rupee))$");
            Assert.IsTrue(theReg.IsMatch(ng_account_currency.Text));
            ngDriver.Highlight(ng_account_currency, highlight_timeout);
            NgWebElement ng_logout_botton = ngDriver.FindElement(NgBy.ButtonText("Logout"));
            ngDriver.Highlight(ng_logout_botton, highlight_timeout);
            ng_logout_botton.Click();
        }
Exemple #28
0
        public void ShouldOpenAccount()
        {
            // switch to "Add Customer" screen
            ngDriver.FindElement(NgBy.ButtonText("Bank Manager Login")).Click();
            ngDriver.FindElement(NgBy.PartialButtonText("Open Account")).Click();

            // fill new Account data
            NgWebElement ng_customer_select = ngDriver.FindElement(NgBy.Model("custId"));

            StringAssert.IsMatch("userSelect", ng_customer_select.GetAttribute("id"));
            ReadOnlyCollection <NgWebElement> ng_customers = ng_customer_select.FindElements(NgBy.Repeater("cust in Customers"));

            // select customer to log in
            NgWebElement account_customer = ng_customers.First(cust => Regex.IsMatch(cust.Text, "Harry Potter*"));

            Assert.IsNotNull(account_customer);
            account_customer.Click();

            NgWebElement ng_currencies_select = ngDriver.FindElement(NgBy.Model("currency"));
            // use core Selenium
            SelectElement       currencies_select  = new SelectElement(ng_currencies_select.WrappedElement);
            IList <IWebElement> account_currencies = currencies_select.Options;
            IWebElement         account_currency   = account_currencies.First(cust => Regex.IsMatch(cust.Text, "Dollar"));

            Assert.IsNotNull(account_currency);
            currencies_select.SelectByText("Dollar");

            // add the account
            var submit_button = ngDriver.FindElement(By.XPath("/html/body//form/button[@type='submit']"));

            StringAssert.IsMatch("Process", submit_button.Text);
            submit_button.Click();

            try {
                alert      = driver.SwitchTo().Alert();
                alert_text = alert.Text;
                StringAssert.StartsWith("Account created successfully with account Number", alert_text);
                alert.Accept();
            } catch (NoAlertPresentException ex) {
                // Alert not present
                verificationErrors.Append(ex.StackTrace);
            } catch (WebDriverException ex) {
                // Alert not handled by PhantomJS
                verificationErrors.Append(ex.StackTrace);
            }

            // Confirm account added for customer
            Assert.IsEmpty(verificationErrors.ToString());

            // switch to "Customers" screen
            ngDriver.FindElement(NgBy.PartialButtonText("Customers")).Click();

            // get customers
            ng_customers = ngDriver.FindElements(NgBy.Repeater("cust in Customers"));
            // discover customer
            NgWebElement ng_customer = ng_customers.First(cust => Regex.IsMatch(cust.Text, "Harry Potter"));

            Assert.IsNotNull(ng_customer);

            // extract the account id from the alert message
            string account_id = alert_text.FindMatch(@"(?<account_id>\d+)$");

            Assert.IsNotNullOrEmpty(account_id);
            // search accounts of specific customer
            ReadOnlyCollection <NgWebElement> ng_customer_accounts = ng_customer.FindElements(NgBy.Repeater("account in cust.accountNo"));

            NgWebElement account_matching = ng_customer_accounts.First(acc => String.Equals(acc.Text, account_id));

            Assert.IsNotNull(account_matching);
            ngDriver.Highlight(account_matching, highlight_timeout);
        }
        public void MarketEventDataCorrect(string frequency)
        {
            // confirm preventing sale of liquor checkbox is selected
            NgWebElement uiPreventingSaleOfLiquor = ngDriver.FindElement(By.CssSelector("mat-checkbox[formcontrolname='isNoPreventingSaleofLiquor']"));

            Assert.Contains("mat-checkbox-checked", uiPreventingSaleOfLiquor.GetAttribute("class"));

            // confirm market managed or carried checkbox is selected
            NgWebElement uiMarketManagedOrCarried = ngDriver.FindElement(By.CssSelector("mat-checkbox[formcontrolname='isMarketManagedorCarried']"));

            Assert.Contains("mat-checkbox-checked", uiMarketManagedOrCarried.GetAttribute("class"));

            // confirm market only vendors checkbox is selected
            NgWebElement uiIsMarketOnlyVendors = ngDriver.FindElement(By.CssSelector("mat-checkbox[formcontrolname='isMarketOnlyVendors']"));

            Assert.Contains("mat-checkbox-checked", uiIsMarketOnlyVendors.GetAttribute("class"));

            // confirm imported goods checkbox is selected
            NgWebElement uiIsNoImportedGoods = ngDriver.FindElement(By.CssSelector("mat-checkbox[formcontrolname='isNoImportedGoods']"));

            Assert.Contains("mat-checkbox-checked", uiIsNoImportedGoods.GetAttribute("class"));

            // confirm six vendors checkbox is selected
            NgWebElement uiIsMarketHostsSixVendors = ngDriver.FindElement(By.CssSelector("mat-checkbox[formcontrolname='isMarketHostsSixVendors']"));

            Assert.Contains("mat-checkbox-checked", uiIsMarketHostsSixVendors.GetAttribute("class"));

            // confirm max amount or duration checkbox is selected
            NgWebElement uiIsMarketMaxAmountorDuration = ngDriver.FindElement(By.CssSelector("mat-checkbox[formcontrolname='isMarketMaxAmountorDuration']"));

            Assert.Contains("mat-checkbox-checked", uiIsMarketMaxAmountorDuration.GetAttribute("class"));

            // confirm contact name is correct
            NgWebElement uiContactName = ngDriver.FindElement(By.CssSelector("input[formcontrolname='contactName']"));

            Assert.True(uiContactName.GetAttribute("value") == "Test Automation");

            // confirm contact phone number is correct
            NgWebElement uiContactPhoneNumber = ngDriver.FindElement(By.CssSelector("input[formcontrolname = 'contactPhone']"));

            Assert.True(uiContactPhoneNumber.GetAttribute("value") == "(222) 222-2222");

            // confirm contact email is correct
            NgWebElement uiContactEmail = ngDriver.FindElement(By.CssSelector("input[formcontrolname = 'contactEmail']"));

            Assert.True(uiContactEmail.GetAttribute("value") == "*****@*****.**");

            // confirm market name is correct
            NgWebElement uiMarketName = ngDriver.FindElement(By.CssSelector("input[formcontrolname = 'marketName']"));

            Assert.True(uiMarketName.GetAttribute("value") == "Point Ellis Market");

            // confirm market website is correct
            NgWebElement uiMarketWebsite = ngDriver.FindElement(By.CssSelector("input[formcontrolname = 'marketWebsite']"));

            Assert.True(uiMarketWebsite.GetAttribute("value") == "http://www.pointellismarketisamazing.com");

            // confirm business legal name is correct
            NgWebElement uiClientHostname = ngDriver.FindElement(By.CssSelector("input[formcontrolname = 'clientHostname']"));

            Assert.True(uiClientHostname.GetAttribute("value") == "Point Ellis Market Cooperative");

            // confirm market event type is correct
            NgWebElement uiMarketEventType = ngDriver.FindElement(By.CssSelector("[formcontrolname= 'marketEventType']"));

            Assert.True(uiMarketEventType.GetAttribute("value") == "2: 845280002");

            // confirm market business number is correct
            NgWebElement uiBusinessNumber = ngDriver.FindElement(By.CssSelector("input[formcontrolname = 'businessNumber']"));

            Assert.True(uiBusinessNumber.GetAttribute("value") == "2222222222222222");

            // confirm incorporation/registration number is correct
            NgWebElement uiRegistrationNumber = ngDriver.FindElement(By.CssSelector("input[formcontrolname = 'registrationNumber']"));

            Assert.True(uiRegistrationNumber.GetAttribute("value") == "1234567");

            // confirm address 1 is correct
            NgWebElement uiStreet1 = ngDriver.FindElement(By.CssSelector("input[formcontrolname = 'street1']"));

            Assert.True(uiStreet1.GetAttribute("value") == "645 Tyee Road");

            // confirm address 2 is correct
            NgWebElement uiStreet2 = ngDriver.FindElement(By.CssSelector("input[formcontrolname = 'street2']"));

            Assert.True(uiStreet2.GetAttribute("value") == "West");

            // confirm city is correct
            NgWebElement uiCity = ngDriver.FindElement(By.CssSelector("input[formcontrolname = 'city']"));

            Assert.True(uiCity.GetAttribute("value") == "Victoria");

            // confirm postal code is correct
            NgWebElement uiPostalCode = ngDriver.FindElement(By.CssSelector("input[formcontrolname = 'postalCode']"));

            Assert.True(uiPostalCode.GetAttribute("value") == "V9A 6X5");

            // confirm additional details are correct
            NgWebElement uiAdditionalDetails = ngDriver.FindElement(By.CssSelector("textarea[formcontrolname='venueDescription']"));

            Assert.True(uiAdditionalDetails.GetAttribute("value") == "Additional details for automated test.");

            if ((frequency == "a one day event") || (frequency == "one day event saved for later"))
            {
                NgWebElement uiFrequency = ngDriver.FindElement(By.CssSelector("[formcontrolname='marketDuration']"));
                Assert.True(uiFrequency.GetAttribute("value") == "3: 845280003");
            }

            if ((frequency == "a weekly event") || (frequency == "a weekly event saved for later"))
            {
                NgWebElement uiFrequency = ngDriver.FindElement(By.CssSelector("[formcontrolname='marketDuration']"));
                Assert.True(uiFrequency.GetAttribute("value") == "0: 845280000");
            }

            if ((frequency == "a monthly event") || (frequency == "a monthly event saved for later"))
            {
                NgWebElement uiFrequency = ngDriver.FindElement(By.CssSelector("[formcontrolname='marketDuration']"));
                Assert.True(uiFrequency.GetAttribute("value") == "2: 845280002");
            }

            if ((frequency == "a bi-weekly event") || (frequency == "a bi-weekly event saved for later"))
            {
                NgWebElement uiFrequency = ngDriver.FindElement(By.CssSelector("[formcontrolname='marketDuration']"));
                Assert.True(uiFrequency.GetAttribute("value") == "1: 845280001");
            }

            // confirm additional information is correct
            NgWebElement uiAdditionalInformation = ngDriver.FindElement(By.CssSelector("textarea[formcontrolname='additionalLocationInformation']"));

            Assert.True(uiAdditionalInformation.GetAttribute("value") == "Additional information for automated test.");

            if ((frequency != "a one day event") || (frequency != "a one day event saved for later"))
            {
                if ((frequency == "a weekly event") || (frequency == "a weekly event saved for later") || (frequency == "a bi-weekly event") || (frequency == "a bi-weekly event saved for later"))
                {
                    // confirm selection re days of the week
                    NgWebElement uiThursdayFinal = ngDriver.FindElement(By.CssSelector("mat-checkbox[formcontrolname='thursday']"));
                    Assert.Contains("mat-checkbox-checked", uiThursdayFinal.GetAttribute("class"));

                    NgWebElement uiFridayFinal = ngDriver.FindElement(By.CssSelector("mat-checkbox[formcontrolname='friday']"));
                    Assert.Contains("mat-checkbox-checked", uiFridayFinal.GetAttribute("class"));

                    NgWebElement uiSaturdayFinal = ngDriver.FindElement(By.CssSelector("mat-checkbox[formcontrolname='saturday']"));
                    Assert.Contains("mat-checkbox-checked", uiSaturdayFinal.GetAttribute("class"));
                }

                if ((frequency == "a monthly event") || (frequency == "a monthly event saved for later"))
                {
                    // confirm selected day of the week
                    NgWebElement uiSaturday3 = ngDriver.FindElement(By.CssSelector("mat-checkbox[formcontrolname='saturday']"));
                    Assert.Contains("mat-checkbox-checked", uiSaturday3.GetAttribute("class"));

                    // confirm selected week of the month
                    NgWebElement uiWeekOfMonth4 = ngDriver.FindElement(By.CssSelector("[formcontrolname='weekOfMonth'] mat-radio-button#mat-radio-10"));
                    Assert.Contains("mat-radio-checked", uiWeekOfMonth4.GetAttribute("class"));
                }

                if (frequency == "an approved monthly event")
                {
                    // confirm selected day of the week
                    NgWebElement uiSaturday3 = ngDriver.FindElement(By.CssSelector("mat-checkbox[formcontrolname='saturday']"));
                    Assert.Contains("mat-checkbox-checked", uiSaturday3.GetAttribute("class"));

                    // confirm selected week of the month
                    NgWebElement uiWeekOfMonth4 = ngDriver.FindElement(By.CssSelector("[formcontrolname='weekOfMonth'] mat-radio-button#mat-radio-15"));
                    Assert.Contains("mat-radio-checked", uiWeekOfMonth4.GetAttribute("class"));
                }
            }

            // confirm event start hour
            NgWebElement uiEventStartHour = ngDriver.FindElement(By.CssSelector("[formcontrolname='startTime'] input[aria-label='Hours']"));

            Assert.True(uiEventStartHour.GetAttribute("value") == "07");

            // confirm event start minute
            NgWebElement uiEventStartMinute = ngDriver.FindElement(By.CssSelector("[formcontrolname='startTime'] input[aria-label='Minutes']"));

            Assert.True(uiEventStartMinute.GetAttribute("value") == "59");

            // confirm event end hour
            NgWebElement uiEventEndHour = ngDriver.FindElement(By.CssSelector("[formcontrolname='endTime'] input[aria-label='Hours']"));

            Assert.True(uiEventEndHour.GetAttribute("value") == "09");

            // confirm event end minute
            NgWebElement uiEventEndMinute = ngDriver.FindElement(By.CssSelector("[formcontrolname='endTime'] input[aria-label='Minutes']"));

            Assert.True(uiEventEndMinute.GetAttribute("value") == "59");

            // confirm liquor sale start hour
            NgWebElement uiLiquorStartHour = ngDriver.FindElement(By.CssSelector("[formcontrolname='liquorStartTime'] input[aria-label='Hours']"));

            Assert.True(uiLiquorStartHour.GetAttribute("value") == "10");

            // confirm liquor sale start minute
            NgWebElement uiLiquorStartMinute = ngDriver.FindElement(By.CssSelector("[formcontrolname='liquorStartTime'] input[aria-label='Minutes']"));

            Assert.True(uiLiquorStartMinute.GetAttribute("value") == "01");

            // confirm liquor sale end hour
            NgWebElement uiLiquorEndHour1 = ngDriver.FindElement(By.CssSelector("[formcontrolname='liquorEndTime'] input[aria-label='Hours']"));

            Assert.True(uiLiquorEndHour1.GetAttribute("value") == "08");

            // confirm liquor sale end minute
            NgWebElement uiLiquorEndMinute1 = ngDriver.FindElement(By.CssSelector("[formcontrolname='liquorEndTime'] input[aria-label='Minutes']"));

            Assert.True(uiLiquorEndMinute1.GetAttribute("value") == "58");

            // confirm serving it right/minors checkbox is selected
            NgWebElement uiServingItRight = ngDriver.FindElement(By.CssSelector("mat-checkbox[formcontrolname='isAllStaffServingitRight']"));

            Assert.Contains("mat-checkbox-checked", uiServingItRight.GetAttribute("class"));

            // confirm sample sizes checkbox is selected
            NgWebElement uiSampleSizes = ngDriver.FindElement(By.CssSelector("mat-checkbox[formcontrolname='isSampleSizeCompliant']"));

            Assert.Contains("mat-checkbox-checked", uiSampleSizes.GetAttribute("class"));

            if ((frequency == "a one day event") || (frequency == "a weekly event") || (frequency == "a bi-weekly event") || (frequency == "a monthly event"))
            {
                // confirm agreement checkbox is selected
                NgWebElement uiAgreement = ngDriver.FindElement(By.CssSelector("mat-checkbox[formcontrolname='agreement']"));
                Assert.Contains("mat-checkbox-checked", uiAgreement.GetAttribute("class"));
            }

            // confirm that LCSD-4211 error is no longer happening
            Assert.True(ngDriver.FindElement(By.XPath("//body[not(contains(.,'Please enter the start date'))]")).Displayed);
        }