public void AbleToCreateNewEmployeeWth_ValidData()
        {
            ExcelLib.PopulateInCollection(Test.Base.ExcelPath, "Employees");
            NavigateToEmployeesPage();

            Driver.wait(2);

            Name.SendKeys(ExcelLib.ReadData(10, "Name"));

            Username.SendKeys(ExcelLib.ReadData(10, "UserName"));

            Edit_Contact.Click();

            Driver.driver.SwitchTo().Frame(Driver.driver.FindElement(By.TagName("iframe")));
            SaveEditContactwithValidData();

            Driver.wait(2);
            Driver.driver.SwitchTo().ParentFrame();

            Password.SendKeys(ExcelLib.ReadData(10, "Password"));

            RetypePassword.SendKeys(ExcelLib.ReadData(10, "Confirm Password"));
            Driver.wait(2);

            if (!IsAdmin.Selected)
            {
                Thread.Sleep(3000);
                IsAdmin.Click();
            }

            Save_btn.Click();
            Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Info, "Save button clicked after entering valid data");

            IWebElement title      = Driver.driver.FindElement(By.XPath("html/body/div[4]/h2"));
            string      page_title = title.Text;

            try
            {
                string URL = Driver.driver.Url;
                Console.WriteLine(URL);
                Assert.AreSame("http://52.65.131.15/User", URL);
                Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "User Navigated back to Administration>Employees Page");
            }
            catch (Exception e)
            {
                Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Still on Create New Employee Page, Should navigate back to Administration>Employees Page");
                Back_to_list.Click();
            }

            try
            {
                Search_For_Record("Valid");
            }
            catch (Exception e)
            {
                Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Employees details are not found in the list. Test Failed");
            }
        }
        public SignupPageSecurity()
        {
            InitializeComponent();
            controls = new List <Entry>
            {
                FirstName, LastName, Email, Password, Mobile
            };

            FirstName.Completed      += (sender, e) => MiddleName.Focus();
            MiddleName.Completed     += (sender, e) => LastName.Focus();
            LastName.Completed       += (s, e) => Mobile.Focus();
            Mobile.Completed         += (s, e) => Email.Focus();
            Email.Completed          += (s, e) => Password.Focus();
            Password.Completed       += (s, e) => RetypePassword.Focus();
            RetypePassword.Completed += (s, e) => SubmitForm(s, e);
        }
Exemplo n.º 3
0
        public void Addemployee()
        {
            //Administrator
            Administrator.Click();
            //Administrator.WaitForElement(TimeSpan.FromSeconds(10));

            //Go to Employee
            Employee.WaitForElement(TimeSpan.FromSeconds(3));

            Employee.Click();


            //Crate new Employee

            Create.Click();

            Name.SendKeys("Industry");

            userName.SendKeys("Connect23");

            Contact.SendKeys("0123456789");

            Password.SendKeys("Abcd@1234)");

            RetypePassword.SendKeys("Abcd@1234)");

            Save.Click();

            BackToList.Click();

            //lastPage.Click();

            //Validation
            if (CommonDriver.driver.FindElement(By.XPath("//*[@id='container']/p/a")).Text == "Create")
            {
                Console.WriteLine("Employee Created Successfully");
            }
            else
            {
                Console.WriteLine("Fail to create Employee");
            }
        }
        public void CreateEmployee_Wth_InvalidData()
        {
            ExcelLib.PopulateInCollection(Test.Base.ExcelPath, "Employees");
            NavigateToEmployeesPage();

            Driver.wait(2);

            Name.SendKeys(ExcelLib.ReadData(2, "Name"));

            Username.SendKeys(ExcelLib.ReadData(2, "UserName"));

            Password.SendKeys(ExcelLib.ReadData(2, "Password"));

            RetypePassword.SendKeys(ExcelLib.ReadData(2, "Confirm Password"));
            Driver.wait(2);

            if (!IsAdmin.Selected)
            {
                Thread.Sleep(3000);
                IsAdmin.Click();
            }

            Save_btn.Click();

            // To check is user is still on the same page.
            try
            {
                IWebElement title      = Driver.driver.FindElement(By.XPath("html/body/div[4]/h2"));
                string      page_title = title.Text;
                Console.WriteLine(page_title);
                Assert.AreEqual("Employee Details", page_title);
                Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Still on Create new Employee Page, Details not added");
            }
            catch (Exception e)
            {
                Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Navigated to a different page");
            }

            // To check if user is getting any error message on entering Invalid data
            try
            {
                IWebElement element      = Driver.driver.FindElement(By.XPath("html/body/div[4]/form/div/div[1]/div/span/span"));
                bool        visible      = element.Displayed;
                string      actual_err   = element.Text;
                string      expected_err = ExcelLib.ReadData(2, "Error_messages");
                try
                {
                    if (visible == true)
                    {
                        Assert.AreEqual(expected_err, actual_err);
                        Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Name Field: Correct error message displayed");
                    }
                }
                catch (Exception e)
                {
                    Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Name Field: Incorrect error message displayed");
                }
            }
            catch (Exception e)
            {
                Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Name Field: Error message missing");
            }

            // Validate error message for UserName Textfield
            try
            {
                IWebElement element      = Driver.driver.FindElement(By.XPath("html/body/div[4]/form/div/div[2]/div/span/span"));
                bool        visible      = element.Displayed;
                string      actual_err   = element.Text;
                string      expected_err = ExcelLib.ReadData(3, "Error_messages");
                try
                {
                    if (visible == true)
                    {
                        Assert.AreEqual(expected_err, actual_err);
                        Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "UserName Field: Correct error message displayed");
                    }
                }
                catch (Exception e)
                {
                    Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "UserName Field: Incorrect error message displayed");
                }
            }
            catch (Exception e)
            {
                Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "UserName Field: Error message missing");
            }


            // Validate error message for Password Textfield
            try
            {
                IWebElement element      = Driver.driver.FindElement(By.XPath("html/body/div[4]/form/div/div[4]/div/span/span"));
                bool        visible      = element.Displayed;
                string      actual_err   = element.Text;
                string      expected_err = ExcelLib.ReadData(4, "Error_messages");
                try
                {
                    if (visible == true)
                    {
                        Assert.AreEqual(expected_err, actual_err);
                        Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Password Field: Correct error message displayed");
                    }
                }
                catch (Exception e)
                {
                    Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Password Field: Incorrect error message displayed");
                }
            }
            catch (Exception e)
            {
                Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Password Field: Error message missing");
            }

            // Calling Search method to verify if invalid record  is created
            try
            {
                Search_For_Record("Invalid");
            }
            catch
            {
                Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Invalid data Record Not Created");
            }
        }
Exemplo n.º 5
0
        // codes of the delete actions

        public void AddEmployee()
        {
            //click the create button

            Administrator.Click();

            //click the employee button
            Employee.Click();

            //click the Create button
            Create.Click();

            //create the Name
            String NameT = "testers";

            Thread.Sleep(2000);

            Name.SendKeys("testers");

            //create the username
            userName.SendKeys("testerss");

            //create the contact

            Contact.SendKeys("1234");

            //create the password

            Password.SendKeys("Sa1234567");

            //retypepassword
            RetypePassword.SendKeys("Sa1234567");

            //click the Save button

            Save.Click();

            //back to the previous page

            BackToList.Click();

            Thread.Sleep(2000);


            //validation
            //if (CommonDrive.driver.FindElement(By.XPath("//*[@id='usersGrid']/div[3]/table/tbody/tr[1]/td[1]")).Text == NameT)
            //{
            //    Console.WriteLine("the new user is located in the first page");
            //}
            //else
            //{
            //    Thread.Sleep(2000);
            //    lastPage.Click();

            //    if (CommonDrive.driver.FindElement(By.XPath("//*[@id='usersGrid']/div[3]/table/tbody/tr[2]/td[1]")).Text == NameT)
            //    {
            //        Console.WriteLine("the new user is created succefully");
            //    }
            //    else
            //    {
            //        Console.WriteLine("the new user is not existing, the test faild");
            //    }


            //}
            //var testpage = CommonDrive.driver.FindElement(By.XPath("//*[@id='usersGrid']/div[3]/table/tbody/tr[1]/td[1]")).Text;
            //Assert.AreEqual(NameT, testpage);
        }