private void SelectCard()
 {
     _driver.ClickElement(
         _driver
         .FindElements(By.ClassName("panel-cards-item"))
         .FirstOrDefault(el => el.FindElements(By.ClassName("panel-card-text"))
                         .FirstOrDefault(x => x.Text == _configuration.CardName) != null));
 }
Example #2
0
 public void EnterSkillDetails(IWebDriver driver, Skill skill)
 {
     ClickTab(driver, SellerDetailType.Skill);
     driver.ClickElement(addNewButton, 3);
     driver.EnterField(skillNameField, skill.Name, 3);
     driver.SelectOptionByValue(skillLevelField, skill.Level, 3);
     driver.ClickElement(saveButton, 3);
 }
Example #3
0
 public void EnterCertificationDetails(IWebDriver driver, Certification certification)
 {
     ClickTab(driver, SellerDetailType.Certification);
     driver.ClickElement(addNewButton, 3);
     driver.EnterField(certificationNameField, certification.Name, 3);
     driver.EnterField(certificationOrgField, certification.Organisation, 3);
     driver.SelectOptionByValue(certificationYearField, certification.Year, 3);
     driver.ClickElement(saveButton, 3);
 }
Example #4
0
 public void EnterLanguageDetails(IWebDriver driver, Language language)
 {
     ClickTab(driver, SellerDetailType.Language);
     driver.ClickElement(addNewButton, 3);
     driver.EnterField(languageNameField, language.Name, 3);
     driver.SelectOptionByValue(languageLevelField, language.Level, 3);
     // handle exception in the test if such option does not exist
     driver.ClickElement(saveButton, 3);
 }
Example #5
0
 public void EnterEducationDetails(IWebDriver driver, Education education)
 {
     ClickTab(driver, SellerDetailType.Education);
     driver.ClickElement(addNewButton, 3);
     driver.EnterField(instituteNameField, education.InstituteName, 3);
     driver.SelectOptionByValue(countryField, education.Country, 3);
     driver.SelectOptionByValue(degreeTitleField, education.DegreeTitle, 3);
     driver.EnterField(degreeNameField, education.DegreeName, 3);
     driver.SelectOptionByValue(graudationYearField, education.YearOfGraduation, 3);
     // handle exception in the test if such option does not exist
     driver.ClickElement(saveButton, 3);
 }
        public void Initialize()
        {
            _driver.Navigate().GoToUrl("https://www.linkedin.com/uas/login");

            _driver.SetTextOnElement("session_key-login", "[your linked username]");
            _driver.SetTextOnElement("session_password-login", "[your linked in password]");
            _driver.ClickElement("btn-primary", true);

            _driver.Navigate().GoToUrl("https://www.linkedin.com/mynetwork/invite-connect/connections/");
            GetTotalNumberOfContacts();
            ScrollToTheBottom();
            ReadContactNamesFromPage();
        }
Example #7
0
        public void ClickTab(IWebDriver driver, SellerDetailType text)
        {
            By location;

            switch (text)
            {
            case SellerDetailType.Language:
                location = languagesTab;
                break;

            case SellerDetailType.Skill:
                location = skillsTab;
                break;

            case SellerDetailType.Education:
                location = educationTab;
                break;

            case SellerDetailType.Certification:
                location = certificationTab;
                break;

            default:
                throw new ArgumentException("Illegal argument was passed '" + text.ToString("G") + "'");
            }
            driver.ClickElement(location, 3);
        }
Example #8
0
        public static void CheckInPerson
        (
            this IWebDriver driver,
            string phoneNumber,
            int familyId,
            int personId,
            int?serviceTimeId   = null,
            string?areaName     = null,
            string?groupName    = null,
            string?abilityLevel = null,
            string?locationName = null
        )
        {
            // Validate parameters
            if (driver == null)
            {
                throw new ArgumentNullException(nameof(driver));
            }

            if (String.IsNullOrWhiteSpace(phoneNumber))
            {
                throw new ArgumentNullException(nameof(phoneNumber));
            }

            if ((phoneNumber.Length != 4 && phoneNumber.Length != 10) || !"^[0-9]+$".Matches(phoneNumber))
            {
                Console.WriteLine($"ERR: '{ phoneNumber }' is not a valid phone number.");

                return;
            }

            // Start check-in process
            driver.ClickElement(By.XPath("//a[contains(@class, 'btn-checkin')]"));
            driver.WaitForPostBack(TimeSpan.FromSeconds(5));

            // Search by phone number
            driver.SendKeysToElement(By.XPath("//input[contains(@id, 'tbPhone') and @type='text']"), phoneNumber);
            driver.ClickElement(By.XPath("//a[contains(@id, 'lbSearch')]"));
            driver.WaitForPostBack(TimeSpan.FromSeconds(5));

            // Select family
            driver.ClickElement(By.XPath($"//div[contains(@id, 'pnlSelectFamilyPostback') and contains(@data-target, '{ familyId }')]"));
            driver.WaitForPostBack(TimeSpan.FromSeconds(5));

            // Select family member
            By xpath = By.XPath($"//div[contains(@id, 'pnlPersonButton')]/a[@data-person-id='{ personId }']");

            if (driver.ElementExists(xpath))
            {
                if (!driver.FindElement(xpath).GetAttribute("class").Contains("active", StringComparison.OrdinalIgnoreCase))
                {
                    driver.ClickElement(xpath);
                }
            }

            driver.ClickElement(By.XPath("//a[contains(@id, 'lbSelect')]"));
            driver.WaitForPostBack(TimeSpan.FromSeconds(5));

            // Select service time
            if (serviceTimeId.HasValue)
            {
                xpath = By.XPath($"//button[@schedule-id='{ serviceTimeId }']");

                if (driver.ElementExists(xpath))
                {
                    driver.ClickElement(xpath);
                    driver.ClickElement(By.XPath("//a[contains(@id, 'lbSelect')]"));
                    driver.WaitForPostBack(TimeSpan.FromSeconds(5));
                }
            }

            // Select area
            if (!String.IsNullOrWhiteSpace(areaName))
            {
                xpath = By.XPath($"//a[text()[contains(., \"{ areaName }\")]]");

                if (driver.ElementExists(xpath))
                {
                    driver.ClickElement(xpath);
                    driver.WaitForPostBack(TimeSpan.FromSeconds(5));
                }
            }

            // Select group
            if (!String.IsNullOrWhiteSpace(groupName))
            {
                xpath = By.XPath($"//a[text()[contains(., \"{ groupName }\")]]");

                if (driver.ElementExists(xpath))
                {
                    driver.ClickElement(xpath);
                    driver.WaitForPostBack(TimeSpan.FromSeconds(5));
                }
            }

            // Select ability level
            if (!String.IsNullOrWhiteSpace(abilityLevel))
            {
                xpath = By.XPath($"//a[text()[contains(., \"{ abilityLevel }\")]]");

                if (driver.ElementExists(xpath))
                {
                    driver.ClickElement(xpath);
                    driver.WaitForPostBack(TimeSpan.FromSeconds(5));
                }
            }

            // Select location
            if (!String.IsNullOrWhiteSpace(locationName))
            {
                xpath = By.XPath($"//a[text()[contains(., \"{ locationName }\")]]");

                if (driver.ElementExists(xpath))
                {
                    driver.ClickElement(xpath);
                    driver.WaitForPostBack(TimeSpan.FromSeconds(5));
                }
            }

            // Finish check-in process
            xpath = By.XPath("//a[contains(@id, 'lbDone')]");

            if (driver.ElementExists(xpath))
            {
                driver.ClickElement(xpath);
                driver.WaitForPostBack(TimeSpan.FromSeconds(5));
            }
            else
            {
                Console.WriteLine($"ERR: Unable to check { familyId }:{ personId } in to { groupName }:{ locationName }");

                driver.ClickElement(By.XPath("//a[contains(@id, 'lbCancel')]"));
                driver.WaitForPostBack(TimeSpan.FromSeconds(5));
            }
        }
        public void VisualTests()
        {
            //*******************
            // #1 TEST
            // Visual checkpoint #1 - Check the login page.
            eyes1.CheckWindow("LoginPage");

            //*******************
            //#2 TEST
            // This will create a test with two test steps.
            driver.ClickElement(By.Id("log-in"), "Login button");

            // Visual checkpoint #2
            eyes2.CheckWindow("LoginPage-NoUsername-NoPassword");

            driver.FindElement(By.Id("username")).SendKeys("Hackathon");
            driver.ClickElement(By.Id("log-in"), "Login button");

            // Visual checkpoint #3
            eyes2.CheckWindow("LoginPage-NoPassword");

            driver.FindElement(By.Id("username")).Clear();
            driver.FindElement(By.Id("password")).SendKeys("password");
            driver.ClickElement(By.Id("log-in"), "Login button");

            // Visual checkpoint #4
            eyes2.CheckWindow("LoginPage-NoUsername");

            //*******************
            //#3 TEST
            driver.FindElement(By.Id("username")).SendKeys("Hackathon");
            driver.ClickElement(By.Id("log-in"), "Login button");

            driver.ClickElement(By.CssSelector("#transactionsTable #amount"), "Recent Trasactions table - Amount column heading");

            // Visual checkpoint #4
            eyes1.CheckWindow("RecentTrans-AmountSort");

            //*******************
            //#4 TEST
            driver.ClickElement(By.CssSelector("#showExpensesChart"), "Compare Expenses link");
            driver.ElementVisible(By.CssSelector("Canvas#canvas"), "Canvas chart");

            // Visual checkpoint #5
            eyes1.CheckWindow("CompareExpense-CanvasChart");

            driver.ClickElement(By.CssSelector("#addDataset"), "Show data for next year link");
            driver.ElementVisible(By.CssSelector("Canvas#canvas"), "Canvas chart");

            // Visual checkpoint #6
            eyes1.CheckWindow("CompareExpense-ChartWith2019Data");

            //*******************
            //#5 TEST
            driver.Url = $"{ConfigurationManager.AppSettings["URL"].ToString()}?showAd=true";
            driver.SendKeysElement(By.Id("username"), "Hackathon", "Username Text field");
            driver.SendKeysElement(By.Id("password"), "Password", "Password Text field");
            driver.ClickElement(By.Id("log-in"), "Login button");

            // Visual checkpoint #7
            eyes1.CheckWindow("CompareAd");

            // End the test.
            eyes1.CloseAsync();
            eyes2.CloseAsync();
        }
Example #10
0
        public void Start(HourFillForm hourFillForm)
        {
            // Goto TrajectPlannerPage
            var trajectPlannerPage = new TrajectPlannerPage(_webDriver);

            // Login user by given username and password
            _webDriver.EnterValue(new List <Tuple <By, string> >
            {
                new Tuple <By, string>(By.Id(OnderwijsOnlinePage.UserNameInput), hourFillForm.Username),
                new Tuple <By, string>(By.Id(OnderwijsOnlinePage.PassWordInput), hourFillForm.Password),
            });

            // Click the login button
            _webDriver.ClickElement(By.Id(OnderwijsOnlinePage.LoginSubmitButton));

            if (_webDriver.Exists(By.Id(OnderwijsOnlinePage.LoginErrorText), 250))
            {
                ExceptionHandler.ShowException("Invalid input", _webDriver.FindElement(By.Id(OnderwijsOnlinePage.LoginErrorText)).Text, _webDriver);
            }

            // Move cursor to bpv menu tab
            _webDriver.MoveCursorToElement(By.XPath(TrajectPlannerPage.BpvMenuTab));

            // Click on bpv anchor tag
            _webDriver.ClickElement(By.XPath(TrajectPlannerPage.BpvAnchor));

            // Check if the bpv page contains a internship
            if (!_webDriver.Exists(By.XPath(TrajectPlannerPage.FirstInternship)))
            {
                ExceptionHandler.ShowException("Non existing", "The requested element does not exist on the page.", _webDriver);
            }

            // Click first internship in table
            _webDriver.ClickElement(By.XPath(TrajectPlannerPage.FirstInternship));

            if (_webDriver.WindowHandles.Count <= 1)
            {
                ExceptionHandler.ShowException("Non existing", "The requested window does not exist.", _webDriver);
            }

            // Switch to the last open window
            _webDriver.SwitchTo().Window(_webDriver.WindowHandles.Last());

            // Open the hours tab
            _webDriver.ClickElement(By.XPath(TrajectPlannerPage.HoursTab));

            // Click the new hours button
            Thread.Sleep(250);
            _webDriver.ClickElement(By.XPath(TrajectPlannerPage.NewHoursBtn));
            Thread.Sleep(250);

            /*
             * Set the value's of the required input fields
             * Bug: Click the input fields for time because else not being able to save
             */

            _webDriver.SetElementValueById(new Tuple <string, string>(TrajectPlannerPage.DateInput, hourFillForm.Date.ToString("dd-MM-yyyy")));

            _webDriver.ClickElement(By.Id(TrajectPlannerPage.StartingTimeInput));
            _webDriver.EnterValue(new Tuple <By, string>(By.Id(TrajectPlannerPage.StartingTimeInput), hourFillForm.StartTime.ToShortTimeString()));

            _webDriver.ClickElement(By.Id(TrajectPlannerPage.EndingTimeInput));
            _webDriver.EnterValue(new Tuple <By, string>(By.Id(TrajectPlannerPage.EndingTimeInput), hourFillForm.EndTime.ToShortTimeString()));

            // Enter the description value
            _webDriver.EnterValue(new Tuple <By, string>(By.Id(TrajectPlannerPage.DescriptionInput), hourFillForm.Description));

            // Click the save button
            _webDriver.ClickElement(By.XPath(TrajectPlannerPage.SaveBtn));
            Thread.Sleep(2000);

            // Everything is done close windows and dispose web driver
            Close();
        }