private void PerformServiceSelectionTest(BrowserType browserType)
        {
            // Initialize web driver
            IWebDriver webDriver = DriverUtilities.CreateDriver(browserType);

            Assert.IsNotNull(webDriver, "Could not acquire driver for :" + browserType);

            webDriver.Navigate().GoToUrl(LocatorHelper.HOME_PAGE_URL);

            // Accept all cookies
            IWebElement acceptAllCookiesButton = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.AcceptAllCookies);

            acceptAllCookiesButton.Click();

            // Click on Service in main menu
            IWebElement serviceMainMenu = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.ServiceMainMenu);

            serviceMainMenu.Click();

            // Click on Automation under Services
            IWebElement automationLink = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.AutomationSubMenu);

            automationLink.Click();

            // Verify the Automation title in tab window
            Assert.AreEqual(webDriver.Title, "Automation", "Missing the title 'Automation'");

            // Verify the Automation title inside the page
            IWebElement automationHeader = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.AutomationHeaderText);

            Assert.AreEqual(automationHeader.Text, "Automation", "Missing the header text 'Automation'");

            // Hover to the Service menu item
            Actions hoverAction = new Actions(webDriver);

            serviceMainMenu = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.ServiceMainMenu);
            hoverAction.MoveToElement(serviceMainMenu).Perform();

            // Ensure Services and Automation links are selected
            string classAttributValue = serviceMainMenu.GetAttribute("class");

            if (!classAttributValue.Contains("selected has-children  expanded level2 hover"))
            {
                Assert.Fail("Service menu not selected and expanded");
            }

            IWebElement automationLinkParent = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.AutomationSubMenuParentLI);

            Assert.IsNotNull(automationLinkParent, "Automation sub menu is not selected");


            // Close the web driver
            DriverUtilities.DisposeDriver(webDriver);
        }
Example #2
0
        private void PerformCountryTest(BrowserType browserType)
        {
            // Initialize the web driver
            IWebDriver webDriver = DriverUtilities.CreateDriver(browserType);

            Assert.IsNotNull(webDriver, "Could not acquire driver for :" + browserType);

            webDriver.Navigate().GoToUrl(LocatorHelper.HOME_PAGE_URL);

            // Accept all cookies
            IWebElement acceptAllCookiesButton = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.AcceptAllCookies);

            acceptAllCookiesButton.Click();

            // Open the countries drop down
            IWebElement dropDown = LocatorHelper.FindHomePageControl(webDriver, HomePageLocatorName.CountryDropDown);

            dropDown.Click();

            // Fetch all country web elements
            IWebElement countryList = LocatorHelper.FindHomePageControl(webDriver, HomePageLocatorName.CountryList);
            IEnumerable <IWebElement> countryEntries = LocatorHelper.FindAllCountries(webDriver, countryList);

            string firstWindowHandle = webDriver.WindowHandles.First();

            // Iterate each country web element (anchor)
            foreach (IWebElement countryEntry in countryEntries)
            {
                // Open a new Tab window for the country
                countryEntry.Click();

                string countryName = countryEntry.Text;

                // Ensure a new Tab window has been opened
                string lastWindowHandle = webDriver.WindowHandles.Last();
                Assert.AreNotEqual(firstWindowHandle, lastWindowHandle, "Could not open link for :" + countryName);

                // Switch the driver to newly opened tab window
                webDriver.SwitchTo().Window(lastWindowHandle);

                // Accept all cookies in the newly opened tab window
                acceptAllCookiesButton = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.AcceptAllCookies);
                if (acceptAllCookiesButton != null)
                {
                    acceptAllCookiesButton.Click();
                }

                // Ensure that the newly opened tab window page has a valid Sogeti logo.
                IWebElement logo = LocatorHelper.FindHomePageControl(webDriver, HomePageLocatorName.SogetiLogo);
                if (logo == null)
                {
                    logo = LocatorHelper.FindHomePageControl(webDriver, HomePageLocatorName.SogetiLogoNetherlands);
                }

                Assert.IsNotNull(logo, "Page not working for :" + countryName);

                // Close the newly opened tab window
                webDriver.Close();

                // Switch the driver back to the original page
                webDriver.SwitchTo().Window(firstWindowHandle);
            }

            // Close the driver.
            DriverUtilities.DisposeDriver(webDriver);
        }
Example #3
0
        private void PerformContactUsTest(BrowserType browserType)
        {
            // Initialize web driver
            IWebDriver webDriver = DriverUtilities.CreateDriver(browserType);

            Assert.IsNotNull(webDriver, "Could not acquire driver for :" + browserType);

            webDriver.Navigate().GoToUrl(LocatorHelper.HOME_PAGE_URL);

            // Accept all cookies
            IWebElement acceptAllCookiesButton = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.AcceptAllCookies);

            acceptAllCookiesButton.Click();

            // Navigate to services and automation page
            IWebElement serviceMainMenu = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.ServiceMainMenu);

            serviceMainMenu.Click();

            IWebElement automationLink = LocatorHelper.FindServicePageControl(webDriver, ServicePageLocatorName.AutomationSubMenu);

            automationLink.Click();

            // Suffix to generate random texts
            string suffix = DateTime.Now.ToString("_yyyy_MM_dd_HH_mm_ss");

            // Generate random texts for required fields
            IWebElement firstName = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.FirstName);

            firstName.SendKeys("FirstName" + suffix);

            IWebElement lastName = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.LastName);

            lastName.SendKeys("LastName" + suffix);

            IWebElement email = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.EMail);

            email.SendKeys(suffix + "@a.com");

            IWebElement phone = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.Phone);

            phone.SendKeys("0049");

            IWebElement country = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.Country);

            country.SendKeys("Germany");

            IWebElement message = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.Message);

            message.SendKeys("some message" + suffix);

            // Click on Agree checkbox
            IWebElement agreement = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.Agreement);

            agreement.Click();


            // Note : Captcha stops the test run here.
            // Captcha has been introduced to stop the automated usage of website hence this does not let us to continue further.
            // Please see the following pseudo code.

            //IWebElement captcha = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.Captcha);

            //IWebElement submit = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.Submit);
            //submit.Click();

            //IWebElement thankYouDiv = LocatorHelper.FindContactUsControl(webDriver, ContactUsLocatorName.ThankYou);
            //if (thankYouDiv == null || !thankYouDiv.Text.Contains("Thank you for contacting us."))
            //    Assert.Fail("Expected 'Thank you message' missing on Contact Us submit action");


            // Exit the driver
            DriverUtilities.DisposeDriver(webDriver);
        }