Пример #1
0
        internal void DeleteListingSkills()
        {
            //Click on Manage LIsting tab
            MgmtListTab.Click();

            Thread.Sleep(1000);

            // Delete skills form managelisting page
            DeleteIcon.Click();

            try
            {
                //Check the popup  "Delete your service" is present or not
                if (PopUp != null)
                {
                    //If yes button found,then click on it and Navigate to Managelisting page
                    YesBtn.Click();
                    Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Yes button found on popup ");
                    string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Yes button found on popup");
                    Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath));
                }

                else
                {
                    Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Yes button is not found on popup ");
                    string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Yes button found on popup");
                    Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath));
                }
            }
            catch (Exception e)
            {
                Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Yes button is not present in Delete service popup " + e.Message);
                string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Yes button is not present in Delete service popup");
                Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath));
            }
        }
Пример #2
0
        internal void ViewListing()
        {
            try
            {
                //Clicking on Management Listing Tab
                MgmtListTab.Click();

                //Populating the test data from Excelsheet
                ExcelLib.PopulateInCollection(Base.ExcelPath, "EditListing");
                string SkillSelected = ExcelLib.ReadData(2, "Title");

                //Assigning the XPath of the whole table
                string TableRow = "//*[@id='listing-management-section']/div[2]/div[1]/table/tbody/tr";

                //Gathering all elements of the table
                var listrows = Global.GlobalDefinitions.driver.FindElements(By.XPath(TableRow));
                foreach (var Row in listrows)

                {
                    // "td[3]" is the third column, Title, in the table. It should match the value in Excelsheet
                    if (Row.FindElement(By.XPath("td[3]")).Text.Equals(SkillSelected))
                    {
                        Thread.Sleep(2000);
                        //When the title matches the value in the Excelsheet then click on the "View Icon" for that particular title.
                        Row.FindElement(By.XPath("td[8]/i[1]")).Click();

                        Base.test.Log(LogStatus.Pass, "A listing is viewable");
                    }
                    else
                    {
                        ShareSkillBtn.Click();
                        //Thread.Sleep(1000);
                        Base.test.Log(LogStatus.Fail, "A listing is  not viewable");
                        SkillsSharePage skillsSharePage = new SkillsSharePage();
                        skillsSharePage.AddNewSkill();
                    }


                    //Verification
                    Thread.Sleep(2000);
                    string ActualValue = Global.GlobalDefinitions.driver.FindElement(By.XPath("//span[@class='skill-title']")).Text;

                    if (SkillSelected.Trim().Equals(ActualValue.Trim()))
                    {
                        Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "A listing cannot be viewed ");
                        string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "A listing is not viewable");
                        Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath));
                    }
                    else
                    {
                        Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "A listing cannot be viewed ");
                        string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "A listing is not viewable");
                        Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath));
                    }
                }
            }

            catch (Exception e)
            {
                Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "A listing cannot be viewed " + e.Message);
                string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "A listing is not viewable");
                Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath));
            }
        }
Пример #3
0
        internal void EditListing()
        {
            //Clicking on the "Manage Listing" tab
            MgmtListTab.Click();

            //Clicking on the "Edit Icon"

            Thread.Sleep(2000);
            EditIcon.Click();
            Thread.Sleep(2000);

            //Populate the Excel Sheet
            GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "EditListing");

            //Edit the Title
            Title.Clear();
            Thread.Sleep(500);
            Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title"));
            Base.test.Log(LogStatus.Pass, "Title has succesfully been edited");

            //Edit the Description
            Description.Clear();
            Thread.Sleep(500);
            Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description"));
            Base.test.Log(LogStatus.Pass, "Description has succesfully been edited");

            //Select a category from dropdown
            GlobalDefinitions.wait(2);
            Actions action = new Actions(GlobalDefinitions.driver);

            action.MoveToElement(category).Build().Perform();
            Thread.Sleep(1000);
            IList <IWebElement> Categorylist = category.FindElements(By.TagName("option"));
            int count = Categorylist.Count;

            Thread.Sleep(1500);
            for (int i = 1; i < count; i++)
            {
                if (Categorylist[i].Text == ExcelLib.ReadData(2, "category").Trim())
                {
                    Thread.Sleep(500);
                    Categorylist[i].Click();
                    Thread.Sleep(500);
                    Base.test.Log(LogStatus.Info, "Category has succesfully been edited");
                }
            }

            //Edit the Subcategory
            Thread.Sleep(2000);
            action.MoveToElement(Subcategory).Build().Perform();
            Thread.Sleep(1000);
            IList <IWebElement> SubCat = Subcategory.FindElements(By.TagName("option"));
            int SubCatCount            = SubCat.Count;

            for (int i = 0; i < SubCatCount; i++)
            {
                if (SubCat[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Subcategory"))
                {
                    SubCat[i].Click();
                    Base.test.Log(LogStatus.Pass, "Subcategory has succesfully been edited");
                }
            }

            //Edit the Tags
            Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags"));
            Thread.Sleep(1000);
            Tags.SendKeys(Keys.Enter);
            Base.test.Log(LogStatus.Pass, "Tag has succesfully been edited");


            //Edit the Service Type-----------------------
            // Storing all the elements under category of 'Service Type' in the list of WebLements
            IList <IWebElement> AllRadioButtons = ServiceListingSection.FindElements(By.XPath("//input[@type='radio'][@name='serviceType']"));
            //Indicating the number of buttons present
            int Size = AllRadioButtons.Count;

            //Starting the loop from the first radio button to the last radio button of Service Type
            for (int i = 0; i < Size; i++)
            {
                //Storing the radio button to the string variable "Value", using the "value" attribute
                string Value = AllRadioButtons.ElementAt(i).GetAttribute("value");
                int    j     = i + 1;
                var    Name  = GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[5]/div[2]/div[1]/div[" + j + "]/div/label")).Text;

                //Checking if Name equals the "name" attribute - "locationType"
                if (Name.Equals(ExcelLib.ReadData(2, "ServiceType")) && Value.Equals("" + i))
                {
                    AllRadioButtons.ElementAt(i).Click();
                    Base.test.Log(LogStatus.Pass, "Service Type has succesfully been edited");
                }
            }
            //Editing the Location Type
            IList <IWebElement> AllTypes = ServiceListingSection.FindElements(By.XPath("//input[@type='radio'][@name='locationType']"));
            int Types = AllTypes.Count;

            for (int i = 0; i < Types; i++)
            {
                string Type = AllTypes.ElementAt(i).GetAttribute("value");
                int    k    = i + 1;
                var    Name = GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']//div[2]/div/form/div[6]/div[2]/div/div[" + k + "]/div/label")).Text;

                //Checking if Name equals the "name" attribute - "locationType"
                if (Name.Equals(ExcelLib.ReadData(2, "LocationType")) && Type.Equals("" + i))
                {
                    AllTypes.ElementAt(i).Click();
                    Base.test.Log(LogStatus.Pass, "Location Type has succesfully been edited");
                }
            }

            // Editing Available Days -Start Date
            Thread.Sleep(1000);
            StartDate.SendKeys(Keys.Delete);
            Thread.Sleep(500);
            StartDate.SendKeys("25/04/2019");
            Thread.Sleep(500);
            StartDate.SendKeys(Keys.Tab);
            Base.test.Log(LogStatus.Pass, "Start Date has succesfully been edited");

            //Editing Available Days - End Date
            Thread.Sleep(1000);
            EndDate.SendKeys(Keys.Delete);
            Thread.Sleep(500);
            EndDate.SendKeys("24/12/2020");
            //EndDate.SendKeys(ExcelLib.ReadData(2, "EndDate"));
            Thread.Sleep(500);
            EndDate.SendKeys(Keys.Tab);
            Base.test.Log(LogStatus.Pass, "End Date has succesfully been edited");


            //Editing Day
            Day.Click();

            //Editing Start Hour
            StartHours.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "StartHour"));

            //Editing End Hour
            GlobalDefinitions.wait(5);
            EndHours.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EndHour"));

            //Editing Skill Trade radio button
            IList <IWebElement> OneSelection = ServiceListingSection.FindElements(By.XPath("//input[@type='radio'][@name='skillTrades']"));
            bool aValue = false;

            aValue = OneSelection.ElementAtOrDefault(0).Selected;
            if (aValue == true)
            {
                OneSelection.ElementAt(1).Click();
                Thread.Sleep(1500);
                Credit.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit"));
                Base.test.Log(LogStatus.Pass, "Skill Trade has succesfully been edited");
            }
            else
            {
                OneSelection.ElementAt(0).Click();
                Thread.Sleep(1500);
                SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "SkillExchange"));
                Base.test.Log(LogStatus.Pass, "Skill Trade has not been edited");
            }

            //Editing "Active" button - whether enable or disable service
            IList <IWebElement> OneRadioButton = ServiceListingSection.FindElements(By.XPath("//input[@type='radio'][@name='isActive']"));
            bool bValue = false;

            bValue = OneRadioButton.ElementAtOrDefault(0).Selected;
            if (bValue == true)
            {
                OneRadioButton.ElementAt(1).Click();
            }
            else
            {
                OneRadioButton.ElementAt(0).Click();
            }

            Thread.Sleep(3000);
            string ActualValue = GlobalDefinitions.ExcelLib.ReadData(2, "Active  Service");

            Thread.Sleep(3000);
            string ExpectedValue = "Hidden";

            if (ExpectedValue.Trim().Equals(ActualValue.Trim()))
            //if (ExpectedValue == ActualValue)
            {
                Base.test.Log(LogStatus.Pass, "Service is disabled");
            }
            else
            {
                Base.test.Log(LogStatus.Fail, "Service is enabled");
            }
            //Clicking on Save Button
            SaveButton.Click();
            Base.test.Log(LogStatus.Pass, "Listing has successfully been edited");

            //Check if the edited skill is present in the Manage Listings
            try
            {
                GlobalDefinitions.wait(2);
                string ExpectedTitle = ExcelLib.ReadData(2, "Title");

                string BeforeXPath = "//div[@id='listing-management-section']/div[2]/div/table/tbody/tr[";
                Thread.Sleep(2000);
                string AfterXpath = "]/td[3]";
                for (int i = 1; i <= 5; i++)
                {
                    GlobalDefinitions.wait(2);
                    string ColElements = driver.FindElement(By.XPath(BeforeXPath + i + AfterXpath)).Text;

                    if (ColElements.Contains(ExpectedTitle))
                    {
                        Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Edited Listing is displayed on the Listing Service page ");
                        string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Edited Listing is displayed on the Listing Service page");
                        Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath));

                        break;
                    }
                    else

                    {
                        Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Edited Listing is not displayed on the Listing Service page ");
                        string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Edited Listing is not displayed on the Listing Service page");
                        Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath));
                    }
                }
            }
            catch (Exception e)
            {
                Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Error while displaying the edited listing" + e.Message);
                string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Error, the listing has not been edited");
                Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath));
            }
        }