Esempio n. 1
0
        public void BlankCredentialsTest()
        {
            test = extent.CreateTest(TestContext.CurrentContext.Test.Name, "Test Login Page with blank values");
            var LoginPage = new LoginPage();

            LoginPage.Login(LoginPage.UserName, "", LoginPage.Password, "", LoginPage.LoginInBtn, LoginPage.Welcometitle);
            BasicMethods.VerifyPartialText(LoginPage.BlankErrorMsg, "The Password field is required.");
            BasicMethods.VerifyText(LoginPage.BlankEmailErrorMsg, "The Email field is required.");
            BasicMethods.VerifyText(LoginPage.BlankPasswordErrorMsg, "The Password field is required.");
            BasicMethods.VerifyText(LoginPage.EmailErrorMsg, "The Email field is required.");
            BasicMethods.VerifyText(LoginPage.PasswordErrorMsg, "The Password field is required.");
        }
Esempio n. 2
0
        public void LoginPageUITest()
        {
            test = extent.CreateTest(TestContext.CurrentContext.Test.Name, "Verify UI");
            var LoginPage   = new LoginPage();
            var ManageUsers = new ManageUsersPage();
            var HomePage    = new HomePage();

            BasicMethods.CheckImage(LoginPage.HPLogo);
            BasicMethods.VerifyPartialText(LoginPage.Welcometitle, "Chemical Ordering Tool - HP Inc.");
            BasicMethods.VerifyText(LoginPage.WelcomeHeader, "Welcome to the Chemical Ordering Tool");
            BasicMethods.VerifyText(LoginPage.WelcomeBanner, "This is a private tool. Explicit authorization from the tool owner is required for access or use. Unauthorized access or use may result in severe civil and/or criminal liability including without limitation under 18 USC Sections 1030 et seq. All rights whatsoever are reserved.");
            BasicMethods.VerifyText(LoginPage.LoginFormTitle, "Please log in using your HP Email and Password");
            BasicMethods.VerifyText(LoginPage.ContactusLink, "Please contact COT Support ([email protected]) if you have questions.");
        }
Esempio n. 3
0
        public void UserAccountActiveTest()
        {
            test = extent.CreateTest(TestContext.CurrentContext.Test.Name, "Scenario to check if the user account is active or inactive ");
            var LoginPage  = new LoginPage();
            var HomePage   = new HomePage();
            var ManageUser = new ManageUsersPage();

            LoginPage.Login(LoginPage.UserName, "*****@*****.**", LoginPage.Password, "July012018", LoginPage.LoginInBtn, LoginPage.Last10RequestsTitle);
            // ManageUser.EditUserNameTest("Durga Prasad", "*****@*****.**", ManageUser.ManageUsersTableRow);
            ManageUser.IsActiveUserFalseTest("Durga Prasad", ManageUser.UserEmailTextBox, "*****@*****.**");
            BasicMethods.ClickBtn(HomePage.LogOffBtn);
            LoginPage.Login(LoginPage.UserName, "*****@*****.**", LoginPage.Password, "Lost4now", LoginPage.LoginInBtn, LoginPage.Welcometitle);
            BasicMethods.VerifyText(LoginPage.BlankErrorMsg, "Sorry, you are not an active user for this website.");
        }
Esempio n. 4
0
        public void UnauthorizedAccessTest()
        {
            test = extent.CreateTest(TestContext.CurrentContext.Test.Name, "Test Login Page with unauthorized user credentials ");
            var LoginPage  = new LoginPage();
            var HomePage   = new HomePage();
            var ManageUser = new ManageUsersPage();

            LoginPage.Login(LoginPage.UserName, "*****@*****.**", LoginPage.Password, "July012018", LoginPage.LoginInBtn, LoginPage.Last10RequestsTitle);
            ManageUser.EditUserFunc("Durga", ManageUser.UserEmailTextBox, "*****@*****.**", ManageUser.UserRole, ManageUser.UserRoleOptions, 2, ManageUser.FirstNameField, "Durga Prasad", ManageUser.LastNameField, "Palukuri", ManageUser.IsUserActiveCheckbox, ManageUser.SaveUserBtn);
            ManageUser.IsActiveUserTrueTest("Durga Prasad", ManageUser.UserEmailTextBox, "*****@*****.**");
            BasicMethods.ClickBtn(HomePage.LogOffBtn);
            LoginPage.Login(LoginPage.UserName, "*****@*****.**", LoginPage.Password, "Lost4now", LoginPage.LoginInBtn, LoginPage.Welcometitle);
            BasicMethods.VerifyText(LoginPage.BlankErrorMsg, "Sorry, you do not have access to this website.");
        }
Esempio n. 5
0
 //Fucntion to check the radio button
 public static void RadioButton(this IWebElement element)
 {
     if (element.GetAttribute("checked") == "true")
     {
         Console.WriteLine("radio button is checked!");
         Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Pass, "radio button is checked!");
     }
     else
     {
         Console.WriteLine("This is one of the unchecked radio buttons!");
         Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, "This is one of the unchecked radio buttons!");
         string s = BasicMethods.TakeScreenShot();
         Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, MarkupHelper.CreateLabel("Observed Image", ExtentColor.Red)).AddScreenCaptureFromPath(s);
     }
 }
Esempio n. 6
0
        //Image Verification function
        public static void CheckImage(this IWebElement element)
        {
            IWebElement ImageFile    = element;
            Boolean     ImagePresent = (Boolean)((IJavaScriptExecutor)DriverUtils.driver).ExecuteScript("return arguments[0].complete && typeof arguments[0].naturalWidth != \"undefined\" && arguments[0].naturalWidth > 0", ImageFile);

            if (ImagePresent)
            {
                Console.WriteLine("Image displayed.");
                Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Pass, "Image exist");
            }
            else
            {
                Console.WriteLine("Image not displayed.");
                string s = BasicMethods.TakeScreenShot();
                Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, MarkupHelper.CreateLabel("Image is missing", ExtentColor.Red)).AddScreenCaptureFromPath(s);
            }
        }
Esempio n. 7
0
        //Fucntion to check if checkbox is checked by default
        public static void CheckBox(this IWebElement element)
        {
            bool isChecked = bool.TryParse(element.GetAttribute("checked"), out isChecked);

            if (isChecked)
            {
                Console.WriteLine("This checkbox is already checked!");
                Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Pass, "This checkbox is already checked!");
            }
            else
            {
                Console.WriteLine("Huh, someone left the checkbox unchecked, lets check it!");
                Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, "Huh, someone left the checkbox unchecked, lets check it!");
                string s = BasicMethods.TakeScreenShot();
                Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, MarkupHelper.CreateLabel(" Test case FAILED due to below issue:", ExtentColor.Red)).AddScreenCaptureFromPath(s);
                //element.Click();
            }
        }
Esempio n. 8
0
        //WebDriver.FindElement(By.id(“Element”),WaitTime)

        //alertBox
        public static void AlertBox(this IWebElement image, IAlert alert)
        {
            alert = DriverUtils.driver.SwitchTo().Alert();
            Console.WriteLine(alert.Text);
            alert.Accept();
            try
            {
                if (image.Displayed)
                {
                    Console.WriteLine("The alert was successfuly accepted and I can see the image!");
                    Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Pass, "The alert was successfuly accepted and I can see the image!");
                }
            }
            catch (NoSuchElementException)
            {
                Console.WriteLine("Something went wrong!!");
                Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, "Something went wrong!!");
                string s = BasicMethods.TakeScreenShot();
                Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, MarkupHelper.CreateLabel(" Test case FAILED due to below issue:", ExtentColor.Red)).AddScreenCaptureFromPath(s);
            }
            Thread.Sleep(3000);
        }
Esempio n. 9
0
        public static void checkWebsite()
        {
            ReadOnlyCollection <IWebElement> links = DriverUtils.driver.FindElements(By.TagName("a"));

            foreach (IWebElement link in links)
            {
                String url = link.GetAttribute("href");
                try
                {
                    WebClient wc         = new WebClient();
                    string    htmlsource = wc.DownloadString(url);
                    Console.WriteLine("The given url\t" + " \t " + url + " \t " + "is working");
                    Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Pass, "The given url\t" + " \t " + url + " \t " + "is working");
                }
                catch (Exception)
                {
                    Console.WriteLine("The given url\t" + " \t " + url + " \t " + "is not working");
                    // Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, "The given url\t" + url + "\t\t" + "is not working");
                    string s = BasicMethods.TakeScreenShot();
                    Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, MarkupHelper.CreateLabel("The given url\t" + " \t " + url + " \t " + "is not working", ExtentColor.Red)).AddScreenCaptureFromPath(s);
                }
            }
        }
Esempio n. 10
0
 public static void DefaultValue(this IWebElement element)
 {
     try
     {
         if (string.IsNullOrEmpty(element.Text) && (string.IsNullOrWhiteSpace(element.Text)))
         {
             Console.WriteLine("Default value is empty");
             Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Pass, "Default value is empty" + "\t" + element.Text);
         }
         else
         {
             Console.WriteLine("Not an empty field by default: \t" + element.Text);
             //Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, "Mismatched text" + "\t" + element.Text);
             string s = BasicMethods.TakeScreenShot();
             Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, MarkupHelper.CreateLabel("Mismatched Text" + "\t" + element.Text, ExtentColor.Red)).AddScreenCaptureFromPath(s);
         }
     }
     catch (AssertionException ex)
     {
         string s = ex.GetBaseException().Message;
         log.Info(s);
     }
 }
Esempio n. 11
0
 public static void validateElementNotPresent(this IWebElement element)
 {
     try
     {
         if (!element.Displayed)
         {
             Console.WriteLine("The given element" + " \t " + " \t " + element.Text + " \t " + "doesnt exist in the webpage");
             Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Pass, "The given element" + " \t " + element.Text + " \t " + "doesnt exist in the webpage");
         }
         else
         {
             Console.WriteLine("The given element" + " \t " + element.Text + " \t " + "is present in the webpage");
             Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, "The given element" + " \t " + element.Text + " \t " + "is present in the webpage");
             string s = BasicMethods.TakeScreenShot();
             Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, MarkupHelper.CreateLabel("Screenshot", ExtentColor.Red)).AddScreenCaptureFromPath(s);
         }
     }
     catch (AssertionException ex)
     {
         string s = ex.GetBaseException().Message;
         log.Info(s);
     }
 }
Esempio n. 12
0
        public static void validateScreenByUrl(String screenUrl)
        {
            String currentURL = DriverUtils.driver.Url;

            try
            {
                if (String.Equals(screenUrl, currentURL))
                {
                    Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Pass, "ValidateScreenByURLTest- Passed");
                }
                else
                {
                    Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, "ValidateScreenByURLTest - Failed");
                    string s = BasicMethods.TakeScreenShot();
                    Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, MarkupHelper.CreateLabel("Mismatch URL screenshot", ExtentColor.Red)).AddScreenCaptureFromPath(s);
                }
            }
            catch (AssertionException ex)
            {
                string s = ex.GetBaseException().Message;
                log.Info(s);
            }
        }
Esempio n. 13
0
        public static void SwitchFrameByID(string value)
        {
            //Getting number of iFrames in webPage
            //Here value is "Id of iframe" for eg : <frame id='test'......</frame>
            //driver.SwitchTo().Frame(driver.FindElement(By.Xpath("//frame[@src='/somesrc' and not(@id='unloadFrame')]")));

            IList <IWebElement> iframe = DriverUtils.driver.FindElements(By.TagName("iframe"));

            int size = iframe.Count;

            try
            {
                if (size != 0)
                {
                    driver.SwitchTo().Frame(value);
                    Console.WriteLine("Switched to Frame ID \t" + value);
                    Log.Info("Frame value" + value);
                    Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Pass, "Switched to frame");
                }
                else
                {
                    //Switch back to default window
                    Console.WriteLine("No frames");
                    log.Info("No frames");
                    string s = BasicMethods.TakeScreenShot();
                    Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, MarkupHelper.CreateLabel("No frames", ExtentColor.Red)).AddScreenCaptureFromPath(s);
                    log.Info("Switching to main frame");
                    driver.SwitchTo().DefaultContent();
                }
            }
            catch (AssertionException ex)
            {
                string s = ex.GetBaseException().Message;
                log.Info(s);
            }
        }
Esempio n. 14
0
        //PartialVerificationText Function

        public static void VerifyPartialText(this IWebElement element, String text)
        {
            try
            {
                if (!string.IsNullOrEmpty(element.Text) && (!string.IsNullOrWhiteSpace(element.Text) && element.Text.Contains(text)))
                {
                    Console.WriteLine("Matched Text:" + "\n" + element.Text);
                    Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Pass, "The given string" + " \t " + element.Text + " \t " + "matches with the expected text" + " \t " + text);
                }
                else
                {
                    Console.WriteLine("Mismatched Text: \n" + element.Text);
                    //Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, "Mismatched text" + "\t" + element.Text);
                    string s = BasicMethods.TakeScreenShot();
                    Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, MarkupHelper.CreateLabel("Mismatched Value" + "\t" + element.Text, ExtentColor.Red)).AddScreenCaptureFromPath(s);
                    Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, "The given string does not exist" + " \t " + element.Text + " \t " + "in the expected string" + " \t " + text);
                }
            }
            catch (AssertionException ex)
            {
                string s = ex.GetBaseException().Message;
                log.Info(s);
            }
        }
Esempio n. 15
0
        public static void validateTitle(String title)
        {
            String currentitle = DriverUtils.driver.Title;

            try
            {
                if (String.Equals(title, currentitle))
                {
                    Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Pass, "The given title \t" + title + "\t matches with the webpage");
                }
                else
                {
                    Common.ExtentReport.test.Log(Status.Fail, "The given title" + " \t " + currentitle + "\t" + " doesn't match with the webpage");
                    Console.WriteLine("Observed Title : " + currentitle);
                    string s = BasicMethods.TakeScreenShot();
                    Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, MarkupHelper.CreateLabel("Mismatch Title screenshot" + " \t ", ExtentColor.Red)).AddScreenCaptureFromPath(s);
                }
            }
            catch (AssertionException ex)
            {
                string s = ex.GetBaseException().Message;
                log.Info(s);
            }
        }