Esempio n. 1
0
        public void DeleteButton()
        {
            /**********************Delete Record Code Starts here*********************/
            Thread.Sleep(1000);
            //Filter option using Buttons Name
            GlobalDef.driver.FindElement(By.XPath("//*[@id='grid']/div[3]/div/table/thead/tr/th[1]/a[1]/span")).Click();

            Thread.Sleep(1000);

            //Enter the filter value
            GlobalDef.Textbox(GlobalDef.driver, "XPath", "/html/body/div[5]/form/div[1]/input[1]", ExcelLib.ReadData(2, "Buttonsname"));

            //Click on Filter button
            GlobalDef.ActionButton(GlobalDef.driver, "XPath", "/html/body/div[5]/form/div[1]/div[2]/button[1]");

            //Click Delete Button in the grid
            GlobalDef.driver.FindElement(By.XPath("//*[@id='grid']/div[4]/table/tbody/tr/td[14]/a[2]")).Click();
            GlobalDef.Wait(GlobalDef.driver, "//*[@id='container']/h2", "visible");

            //populating the test data to collections
            ExcelLib.PopulateInCollection(@"C:\Users\ReshNikesh\Desktop\Study\Testing\SeleniumPrac\FirstProj\TestData1.xlsx", "ButtonsPage");

            //Delete Page Screenshot
            GlobalDef.SaveScreenshot(GlobalDef.driver, "DeletePage1");

            //Verify navigation to Delete confirmation Page
            if (GlobalDef.driver.FindElement(By.XPath("//*[@id='container']/h3")).Text == "Are you sure you want to delete this?")
            {
                if (GlobalDef.driver.FindElement(By.XPath("//*[@id='container']/div/dl/dd[1]")).Text.Contains(ExcelLib.ReadData(2, "Buttonsname")))
                {
                    GlobalDef.driver.FindElement(By.XPath("//*[@id='container']/div/form/div/input")).Click();
                    Thread.Sleep(1000);
                    //Verifying the Newly Edited record

                    if (GlobalDef.driver.FindElement(By.XPath("//*[@id='container']/h2")).Text.Contains("Buttons"))
                    {
                        //Explicit Wait for 2 sec
                        Thread.Sleep(2000);

                        //Filter option using Buttons Name
                        GlobalDef.driver.FindElement(By.XPath("//*[@id='grid']/div[3]/div/table/thead/tr/th[1]/a[1]/span")).Click();

                        Thread.Sleep(1000);

                        //Enter the filter value
                        GlobalDef.Textbox(GlobalDef.driver, "XPath", "/html/body/div[5]/form/div[1]/input[1]", ExcelLib.ReadData(2, "Buttonsname"));

                        //Click on Filter button
                        GlobalDef.ActionButton(GlobalDef.driver, "XPath", "/html/body/div[5]/form/div[1]/div[2]/button[1]");

                        if (GlobalDef.driver.FindElement(By.XPath("//*[@id='grid']/div[5]/span[2]")).Text.Contains("No items to display"))
                        {
                            //Delete Page Screenshot
                            GlobalDef.SaveScreenshot(GlobalDef.driver, "DeletePageSuccess");

                            Console.WriteLine("{0} record deleted successfully", ExcelLib.ReadData(2, "Buttonsname"));
                            //Logging Status in Test Report
                            //ButtonsPageTests.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Button " + ExcelLib.ReadData(2, "Buttonsname") + " is deleted successfully, Test Pass ");
                            SpecFlow.ButtonsSpecFlowFeatureSteps.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Button " + ExcelLib.ReadData(2, "Buttonsname") + " is deleted successfully, Test Pass ");
                        }
                        else
                        {
                            Console.WriteLine("Record not deleted succesfully");
                            //Logging Status in Test Report
                            // ButtonsPageTests.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Button " + ExcelLib.ReadData(2, "Buttonsname") + " is not deleted, Test Failed ");
                            SpecFlow.ButtonsSpecFlowFeatureSteps.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Button " + ExcelLib.ReadData(2, "Buttonsname") + " is not deleted, Test Failed ");
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Button Name: {0} not available in Delete Page ", ExcelLib.ReadData(2, "Buttonsname"));
                    //Logging Status in Test Report
                    //ButtonsPageTests.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Button " + ExcelLib.ReadData(2, "Buttonsname") + " is not available in Delete Page, Test Failed ");
                    SpecFlow.ButtonsSpecFlowFeatureSteps.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Button " + ExcelLib.ReadData(2, "Buttonsname") + " is not available in Delete Page, Test Failed ");
                }
            }
            /********************Delete Code Ends Here**************/
        }
Esempio n. 2
0
        //       ****************************BUTTONS Add CODE END HERE****************************************************************/



        public void EditButton()
        {
            /************************************EDIT BUTTON CODE************************************/
            //populating the test data to collections
            ExcelLib.PopulateInCollection(@"C:\Users\ReshNikesh\Desktop\Study\Testing\SeleniumPrac\FirstProj\TestData1.xlsx", "ButtonsPage");

            //Buttons Name Filter
            GlobalDef.driver.FindElement(By.XPath(".//*[@id='grid']/div[3]/div/table/thead/tr/th[1]/a[1]/span")).Click();

            //Explicit wait
            Thread.Sleep(1000);

            //Enter the filter value
            GlobalDef.Textbox(GlobalDef.driver, "XPath", "/html/body/div[5]/form/div[1]/input[1]", ExcelLib.ReadData(2, "Buttonsname"));

            //Click on Filter button
            GlobalDef.ActionButton(GlobalDef.driver, "XPath", "html/body/div[5]/form/div[1]/div[2]/button[1]");

            //Defining ButtonName in the grid
            buttonNameGrid = GlobalDef.driver.FindElement(By.XPath(".//*[@id='grid']/div[4]/table/tbody/tr/td[1]"));

            //Finding the record to edit
            if (buttonNameGrid.Text == ExcelLib.ReadData(2, "Buttonsname"))
            {
                //Click on Edit Button
                GlobalDef.ActionButton(GlobalDef.driver, "XPath", ".//*[@id='grid']/div[4]/table/tbody/tr/td[14]/a[1]");
                //Implicit Wait
                GlobalDef.driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(2));
                //new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementExists((By.XPath("html/body/div[8]/div[1]/span"))));
                // GlobalDef.Wait(driver, "html/body/div[8]/div[1]/span");
                //Defining Modify popup
                IWebElement Modifypopup = GlobalDef.driver.FindElement(By.XPath("/html/body/div[7]/div[1]/span"));

                //Verify the Modify pop-up
                if (Modifypopup.Text == "Modify" || Modifypopup.Text == "Edit")
                {
                    //Edit Value in the modify Page
                    //Implicit Wait
                    GlobalDef.Wait(GlobalDef.driver, "/html/body/div[7]/div[2]/div/div[2]/input", "visible");

                    //Modify Webelement for ButtonName
                    GlobalDef.Textbox(GlobalDef.driver, "XPath", "/html/body/div[7]/div[2]/div/div[2]/input", ExcelLib.ReadData(3, "Buttonsname"));

                    //Implicit Wait
                    GlobalDef.Wait(GlobalDef.driver, "/html/body/div[7]/div[2]/div/div[4]/input", "visible");
                    //Modify Webelement for ButtonDisplayTitle
                    GlobalDef.Textbox(GlobalDef.driver, "XPath", "/html/body/div[7]/div[2]/div/div[4]/input", ExcelLib.ReadData(3, "BDispValue"));
                    //Thread.Sleep(1000);

                    //Modify Webelement for ButtonLogo
                    GlobalDef.driver.FindElement(By.XPath("/html/body/div[7]/div[2]/div/div[6]/span/span/span[2]/span")).Click();
                    IList <IWebElement> bL = GlobalDef.driver.FindElements(By.XPath("/html/body/div[8]/div/ul/li"));
                    try
                    {
                        foreach (IWebElement e in bL)
                        {
                            if (e.Text.Contains(ExcelLib.ReadData(3, "BLogo")))
                            {
                                e.Click();
                                break;
                            }
                        }
                    }
                    catch
                    {
                        throw new NoSuchElementException("Can't find value as " + ExcelLib.ReadData(3, "BLogo") + "in Button Logo dropdown");
                    }

                    //GlobalDef.Wait(driver, "/html/body/div[7]/div[2]/div/div[6]/span/span/span[2]/span", "visible");
                    //driver.FindElement(By.XPath("/html/body/div[7]/div[2]/div/div[6]/span/span/span[2]/span")).Click();

                    ////Implicit Wait till element is clicked
                    //GlobalDef.Wait(driver, "/html/body/div[8]/div/ul/li[7]/table/tbody/tr/td[2]", "visible");
                    //new WebDriverWait(driver, TimeSpan.FromSeconds(Convert.ToDouble(20))).Until(ExpectedConditions.ElementExists(By.XPath("/html/body/div[8]/div/ul/li[7]/table/tbody/tr/td[2]"))).Click();
                    ////GlobalDef.Wait(driver, "/html/body/div[8]/div/ul/li[7]/table/tbody/tr/td[2]", "clickable");


                    //Modify Webelement for PreCondition
                    //Implicit Wait
                    //GlobalDef.Wait(driver, "/html/body/div[7]/div[2]/div/div[8]/input","visible");
                    GlobalDef.Textbox(GlobalDef.driver, "XPath", "/html/body/div[7]/div[2]/div/div[8]/input", ExcelLib.ReadData(3, "BPreCValue"));


                    //Modify Webelement for Entity Type
                    GlobalDef.driver.FindElement(By.XPath("/html/body/div[7]/div[2]/div/div[18]/span/span/span[2]/span")).Click();
                    IList <IWebElement> eT = GlobalDef.driver.FindElements(By.XPath("//*[@id='ETT_DBID_listbox']/li"));
                    try
                    {
                        foreach (IWebElement e in eT)
                        {
                            if (ExcelLib.ReadData(3, "Entity Type").Equals(e.Text))
                            {
                                e.Click();
                                break;
                            }
                        }
                    }
                    catch
                    {
                        throw new NoSuchElementException("Can't find" + ExcelLib.ReadData(3, "Entity Type") + " in Entity type dropdown");
                    }

                    //Edit Page Screenshot
                    GlobalDef.SaveScreenshot(GlobalDef.driver, "EditPage");

                    //Create Webelement for Update button
                    GlobalDef.driver.FindElement(By.XPath("/html/body/div[7]/div[2]/div/div[27]/a[1]")).Click();
                    Thread.Sleep(1000);

                    //Verifying the Newly Edited record

                    if (buttonHdr.Text == "Buttons")
                    {
                        //Explicit Wait for 2 sec
                        Thread.Sleep(2000);

                        //Filter option using Buttons Name
                        GlobalDef.driver.FindElement(By.XPath("//*[@id='grid']/div[3]/div/table/thead/tr/th[1]/a[1]/span")).Click();

                        Thread.Sleep(1000);

                        //Enter the filter value
                        GlobalDef.Textbox(GlobalDef.driver, "XPath", "/html/body/div[5]/form/div[1]/input[1]", ExcelLib.ReadData(3, "Buttonsname"));

                        //Click on Filter button
                        GlobalDef.ActionButton(GlobalDef.driver, "XPath", "/html/body/div[5]/form/div[1]/div[2]/button[1]");

                        //Create Webelement for Edit button in the grid
                        editbGrid = GlobalDef.driver.FindElement(By.XPath(".//*[@id='grid']/div[4]/table/tbody/tr/td[14]/a[1]"));

                        //Create Webelement for Delete button in the grid
                        deletebGrid = GlobalDef.driver.FindElement(By.XPath(".//*[@id='grid']/div[4]/table/tbody/tr/td[14]/a[2]"));

                        //Create Webelement for Buttonname in the grid
                        //buttonNameGrid = driver.FindElement(By.XPath(".//*[@id='grid']/div[4]/table/tbody/tr/td[1]"));
                        if (editbGrid.Text == "Edit" && deletebGrid.Text == "Delete")
                        {
                            //Edit Successful Screenshot
                            GlobalDef.SaveScreenshot(GlobalDef.driver, "EditSuccessfulPage");

                            Console.WriteLine("Record {0} edited successfully to {1}", ExcelLib.ReadData(2, "Buttonsname"), ExcelLib.ReadData(3, "Buttonsname"));
                            //Logging Status in Test Report
                            // ButtonsPageTests.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Button " + ExcelLib.ReadData(2, "Buttonsname")+" edited successfully to "+ ExcelLib.ReadData(3, "Buttonsname")+ ", Test Passed");
                            SpecFlow.ButtonsSpecFlowFeatureSteps.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Button " + ExcelLib.ReadData(2, "Buttonsname") + " edited successfully to " + ExcelLib.ReadData(3, "Buttonsname") + ", Test Passed");
                        }
                        else
                        {
                            Console.WriteLine("Record {0} was not edited successfully to {0}Edit ButtonsName", Buttonsname);
                            //Logging Status in Test Report
                            //  ButtonsPageTests.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Button " + ExcelLib.ReadData(2, "Buttonsname") + " is not edited successfully to " + ExcelLib.ReadData(3, "Buttonsname") + ", Test Failed");
                            SpecFlow.ButtonsSpecFlowFeatureSteps.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Button " + ExcelLib.ReadData(2, "Buttonsname") + " is not edited successfully to " + ExcelLib.ReadData(3, "Buttonsname") + ", Test Failed");
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Edit page not available, Test Failed");
                    //Logging Status in Test Report
                    // ButtonsPageTests.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Edit Page Not Available, Test Failed");
                    SpecFlow.ButtonsSpecFlowFeatureSteps.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Edit Page Not Available, Test Failed");
                }
            }
            else
            {
                Console.WriteLine("{0} record not found in the grid to edit", Buttonsname);
                //Logging Status in Test Report
                //  ButtonsPageTests.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Button " + ExcelLib.ReadData(2, "Buttonsname") + " not found in the grid to edit");
                SpecFlow.ButtonsSpecFlowFeatureSteps.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Edit Page Not Available, Test Failed");
            }
            /*****************Edit Code Ends Here*************************/
        }