public void ValidateServiceDetail()
        {
            //Wait until the page loads and description is visible
            Wait.ElementIsVisible(driver, "XPath", "//*[@id='service-detail-section']/div[2]/div/div[2]/div[1]/div[1]/div[2]/div[2]/div/div/div[1]/div/div/div/div[1]");

            //Read the Skill exchange tag count from the excel
            var SkillExchngCount = ServiceData.TagsCntData(RowNum);

            //Convert the count of the skill exchange tags from String to integer
            int Count = Int32.Parse(SkillExchngCount);

            //Convert the Start Date and End Data format from (dd/mm/yyyy to yyyy-mm-dd)
            String StartDate = (ServiceData.StrtDateData(RowNum).Substring(4, 4)) + "-" + (ServiceData.StrtDateData(RowNum).Substring(2, 2)) + "-" + (ServiceData.StrtDateData(RowNum).Substring(0, 2));
            String EndDate   = (ServiceData.EndDateData(RowNum).Substring(4, 4)) + "-" + (ServiceData.EndDateData(RowNum).Substring(2, 2)) + "-" + (ServiceData.EndDateData(RowNum).Substring(0, 2));

            //Validate the expected and actual values of the different fields in the services
            Assert.Multiple(() =>
            {
                Assert.That(titleServiceDetail.Text, Is.EqualTo(ServiceData.TitleData(RowNum)));
                Assert.That(DescServiceDetail.Text, Is.EqualTo(ServiceData.DescriptionData(RowNum)));
                Assert.That(CategoryServiceDetail.Text, Is.EqualTo(ServiceData.CategData(RowNum)));
                Assert.That(SubCategoryServiceDetail.Text, Is.EqualTo(ServiceData.SubCategData(RowNum)));
                Assert.That(ServTypeServiceDetail.Text, Is.EqualTo(ServiceData.SrvcTypeData(RowNum)));
                Assert.That(StartDateServiceDetail.Text, Is.EqualTo(StartDate));
                Assert.That(EndDateServiceDetail.Text, Is.EqualTo(EndDate));
                Assert.That(LocationTypeServiceDetail.Text, Is.EqualTo(ServiceData.LocatnTypeData(RowNum)));
            });

            //If the skill trade is chosen as "Skill-exchange" then need to validate the Skill exchange tags
            if (ServiceData.SkillTrdeData(RowNum) == "Skill-exchange")
            {
                String[] SkillsTradeData   = new String[Count];
                String[] SkillExchangeData = ServiceData.SkillExchangeData(RowNum);
                for (int Counter = 0; Counter < Count; Counter++)
                {
                    SkillsTradeData[Counter] = driver.FindElement(By.XPath("//*[@id='service-detail-section']/div[2]/div/div[2]/div[1]/div[1]/div[2]/div[2]/div/div/div[4]/div[2]/div/div/div[2]/span[" + (Counter + 1) + "]")).Text;
                    TestContext.WriteLine(SkillsTradeData[Counter]);
                    Assert.That(SkillsTradeData[Counter], Is.EqualTo(SkillExchangeData[Counter]));
                }

                //Click on the Manage Listings
                ManageLstings.Click();

                //Wait until the Listings are available in the Manage Listing page
                Wait.ElementIsVisible(driver, "XPath", "//*[@id='listing-management-section']/div[2]/div[1]/div[1]/table/tbody/tr/td[4]");
            }

            //If the Skill Exchange is chosen as 'Credit' then validate the credit charge value displayed
            else if (ServiceData.SkillTrdeData(RowNum) == "Credit")
            {
                try
                {
                    String SkillsTrade = SkillsTradeDisplay.Text;

                    //Enter the title in the serach Box
                    SearchBox.SendKeys(ServiceData.TitleData(RowNum));

                    //Press enter key to search for the skill
                    SearchBox.SendKeys(Keys.Enter);

                    //Implicit wait for the registeration pop up to be available
                    Wait.wait(2, driver);

                    String CreditCharge    = "Charge is :$" + ServiceData.CreditValue(RowNum);
                    String CreditActualVal = Charge.Text;
                    Assert.Multiple(() =>
                    {
                        Assert.That(CreditActualVal, Is.EqualTo(CreditCharge));
                        Assert.That(SkillsTrade, Is.EqualTo("None Specified"));
                    });

                    //Click on the Manage Listings
                    MngLstngs.Click();

                    //Wait until the Listings are available in the Manage Listing page
                    Wait.ElementIsVisible(driver, "XPath", "//*[@id='listing-management-section']/div[2]/div[1]/div[1]/table/tbody/tr/td[4]");
                }catch (Exception e)
                {
                    Assert.Fail("One or more webelements could not be found", e.Message);
                }
            }
        }
        public void EditServices()
        {
            //Wait for the Page to be loaded to edit by waiting for the title field to be visible
            Wait.ElementIsVisible(driver, "XPath", "//*[@id='service-listing-section']/div[2]/div/form/div[1]/div/div[2]/div/div[1]/input");

            //Clear the title
            Title.Clear();

            //Enter the updated data into the title field
            Title.SendKeys(ServiceData.TitleData(RowNum));

            //Clear the description field
            Description.Clear();

            //Enter the updated description
            Description.SendKeys(ServiceData.DescriptionData(RowNum));

            //Identify the Category
            SelectElement CategorySelect = new SelectElement(Category);

            //Select the required Category from the dropdown
            CategorySelect.SelectByText(ServiceData.CategData(RowNum));

            //Identify the SubCategory
            SelectElement SubCategorySelect = new SelectElement(SubCategory);

            //Select the required SubCategory from the dropdown
            SubCategorySelect.SelectByText(ServiceData.SubCategData(RowNum));

            //Enter the additional tag to be added
            Tags.SendKeys(ServiceData.TagsData(RowNum));
            Tags.SendKeys(Keys.Enter);

            //Convert the count of Skill Exchange Tags from String to integer
            int Count = Int32.Parse(ServiceData.TagsCntData(RowNum));

            //Invoke the function to choose the Service Type
            ChooseServiceType(ServiceData.SrvcTypeData(RowNum));

            //Invoke the function to choose the Location Type
            ChooseLocationType(ServiceData.LocatnTypeData(RowNum));

            //Invoke the function to choose the Skills Trade Type
            ChooseSkillTrade(ServiceData.SkillTrdeData(RowNum), Count);

            //Clear the field before adding the date
            StartDate.Clear();

            //Enter the data for 'Start date' from excel
            StartDate.SendKeys(ServiceData.StrtDateData(RowNum));

            //Click on the 'End date' field
            EndDate.Click();

            //Clear the 'End date'
            EndDate.Clear();

            //Enter the data for 'End date' from excel
            EndDate.SendKeys(ServiceData.EndDateData(RowNum));

            //Click on the Save button
            SaveButton.Click();
        }
Beispiel #3
0
        public void ViewListings()
        {
            //Implicit wait until the listings are visible
            Wait.wait(2, driver);

            //Validate the Listings in the Manage Listings Page by checking the values displayed for all the fields with the values from excel

            //Read the data for Title from excel into a variable
            var TitleData = ServiceData.TitleData(RowNum);

            //Read the data for Category from excel into a variable
            var CategoryData = ServiceData.CategData(RowNum);

            //Read the data for Description from excel into a variable
            var DescriptionData = ServiceData.DescriptionData(RowNum);

            String DescriptionDataTrunc = "";
            String Description          = "";

            //Truncate the string (only 70 characters of description gets displayed in the Manage listing)
            if (DescriptionData.Length > 70)
            {
                DescriptionDataTrunc = DescriptionData.Substring(0, 70);
                Description          = DescriptionListing.Text.Substring(0, 70);
            }
            else
            {
                DescriptionDataTrunc = DescriptionData;
                Description          = DescriptionListing.Text;
            }

            //Read the data for Service Type from excel into a variable
            var ServiceTypeData = ServiceData.SrvcTypeData(RowNum);

            //Read the data for Service Type from excel into a variable
            var SkillTradeData = ServiceData.SkillTrdeData(RowNum);

            //Read the data for Service Type from excel into a variable
            var ActiveStatusData = ServiceData.ActvStatusData(RowNum);

            //Set a flag as per the status of Active provided by user
            bool ActiveStatusSet = false;

            if (ActiveStatusData == "Active")
            {
                ActiveStatusSet = true;
            }
            else if (ActiveStatusData == "Hidden")
            {
                ActiveStatusSet = false;
            }

            //Assert statements to validate the various fields of the listings
            Assert.Multiple(() =>
            {
                Assert.That(TitleData, Is.EqualTo(TitleListing.Text));
                Assert.That(DescriptionDataTrunc, Is.EqualTo(Description));
                Assert.That(CategoryData, Is.EqualTo(CategoryListing.Text));
                Assert.That(ServiceTypeData, Is.EqualTo(ServiceTypeListing.Text));
                Assert.That(ActiveStatusSet, Is.EqualTo(ActiveStatusListing.Selected));
            });
        }
        public void FillDetailsOfServiceProvided()
        {
            //Wait for the share skill page to be loaded and until title field text box is visible
            Wait.ElementIsVisible(driver, "XPath", "//*[@id='service-listing-section']/div[2]/div/form/div[1]/div/div[2]/div/div[1]/input");

            //Read the data for Title from excel and enter the data into the Title Textbox
            Title.SendKeys(ServiceData.TitleData(RowNum));

            //Read the data for Description from excel and enter the data into the Description Textbox
            Description.SendKeys(ServiceData.DescriptionData(RowNum));

            //Read the Category name from the excel
            var CategoryData = ServiceData.CategData(RowNum);

            //Read the Subcategory name from the excel
            var SubCategoryData = ServiceData.SubCategData(RowNum);

            SelectElement CategorySelect = new SelectElement(Category);

            //Select the required Category from the dropdown
            CategorySelect.SelectByText(CategoryData);

            SelectElement SubCategorySelect = new SelectElement(SubCategory);

            //Select the required SubCategory from the dropdown
            SubCategorySelect.SelectByText(SubCategoryData);

            //Read the Skill exchange tag count from the excel
            var SkillExchngCount = ServiceData.TagsCntData(RowNum);

            int Count     = Int32.Parse(SkillExchngCount);
            int TagsCount = Int32.Parse(ServiceData.TagsDataCount(RowNum));

            int DaysCnt = Int32.Parse(ServiceData.AvailableDaysCnt(RowNum));

            //Fill in the Start and End times for all days
            for (int TagCount = 0; TagCount < TagsCount; TagCount++)
            {
                //Read the data for Tags from excel and enter the data into the Tags field
                Tags.SendKeys(ExcelLibHelpers.ReadData((TagCount + RowNum), "Tags"));

                //Press ENTER key to add the tag
                Tags.SendKeys(Keys.Enter);
            }

            //Read the Service Type data from excel into a variable
            var ServiceTypeData = ServiceData.SrvcTypeData(RowNum);

            //Read the Location Type data from excel into a variable
            var LocationTypeData = ServiceData.LocatnTypeData(RowNum);

            //Read the Skill Trade data from excel into a variable
            var SkillTradeData = ServiceData.SkillTrdeData(RowNum);

            //Read the Active Status data from excel into a variable
            var ActiveStatusData = ServiceData.ActvStatusData(RowNum);

            //Choose Service Type
            ChooseServiceType(ServiceTypeData);

            //Choose Location Type
            ChooseLocationType(LocationTypeData);

            //Choose Skill Trade
            ChooseSkillTrade(SkillTradeData, Count);

            //Click on the 'Start date' field
            StartDate.Click();

            //Read the Start Date data from the excel
            var StartDateData = ServiceData.StrtDateData(RowNum);

            //Read the End Date data from the excel
            var EndDateData = ServiceData.EndDateData(RowNum);

            //Initialse the variable that hold StartTime and EndTime
            var StartTimeData = "000000";
            var EndTimeData   = "000000";

            //Clear the field before adding the date
            StartDate.Clear();

            //Enter the data for 'Start date' from excel
            StartDate.SendKeys(StartDateData);

            Wait.wait(1, driver);

            //Click on the 'End date' field
            EndDate.Click();

            //Clear the 'End date'
            EndDate.Clear();

            //Enter the data for 'End date' from excel
            EndDate.SendKeys(EndDateData);


            //Select the Start time, End time, Available Days
            for (int DaysCount = 0; DaysCount < DaysCnt; DaysCount++)
            {
                if (ServiceData.AvailableDays(RowNum) == "Sun")
                {
                    CheckBox[0].Click();
                    StartTimeData = ServiceData.StrtTimeData(RowNum);
                    EndTimeData   = ServiceData.EndTimeData(RowNum);
                    StartTime[0].Click();
                    StartTime[0].SendKeys(StartTimeData);
                    EndTime[0].Click();
                    EndTime[0].SendKeys(EndTimeData);
                }
                else if (ServiceData.AvailableDays(RowNum) == "Mon")
                {
                    StartTimeData = ServiceData.StrtTimeData(RowNum);
                    EndTimeData   = ServiceData.EndTimeData(RowNum);
                    CheckBox[1].Click();
                    StartTime[1].Click();
                    StartTime[1].SendKeys(StartTimeData);
                    EndTime[1].Click();
                    EndTime[1].SendKeys(EndTimeData);
                }
                else if (ServiceData.AvailableDays(RowNum) == "Tue")
                {
                    StartTimeData = ServiceData.StrtTimeData(RowNum);
                    EndTimeData   = ServiceData.EndTimeData(RowNum);
                    CheckBox[2].Click();
                    StartTime[2].Click();
                    StartTime[2].SendKeys(StartTimeData);
                    EndTime[2].Click();
                    EndTime[2].SendKeys(EndTimeData);
                }
                else if (ServiceData.AvailableDays(RowNum) == "Wed")
                {
                    StartTimeData = ServiceData.StrtTimeData(RowNum);
                    EndTimeData   = ServiceData.EndTimeData(RowNum);
                    CheckBox[3].Click();
                    StartTime[3].Click();
                    StartTime[3].SendKeys(StartTimeData);
                    EndTime[3].Click();
                    EndTime[3].SendKeys(EndTimeData);
                }
                else if (ServiceData.AvailableDays(RowNum) == "Thu")
                {
                    StartTimeData = ServiceData.StrtTimeData(RowNum);
                    EndTimeData   = ServiceData.EndTimeData(RowNum);
                    CheckBox[4].Click();
                    StartTime[4].Click();
                    StartTime[4].SendKeys(StartTimeData);
                    EndTime[4].Click();
                    EndTime[4].SendKeys(EndTimeData);
                }
                else if (ServiceData.AvailableDays(RowNum) == "Fri")
                {
                    StartTimeData = ServiceData.StrtTimeData(RowNum);
                    EndTimeData   = ServiceData.EndTimeData(RowNum);
                    CheckBox[5].Click();
                    StartTime[5].Click();
                    StartTime[5].SendKeys(StartTimeData);
                    EndTime[5].Click();
                    EndTime[5].SendKeys(EndTimeData);
                }
                else
                {
                    StartTimeData = ServiceData.StrtTimeData(RowNum);
                    EndTimeData   = ServiceData.EndTimeData(RowNum);
                    CheckBox[6].Click();
                    StartTime[6].Click();
                    StartTime[6].SendKeys(StartTimeData);
                    EndTime[6].Click();
                    EndTime[6].SendKeys(EndTimeData);
                }
                RowNum++;
            }


            //Choose the Active status button
            ChooseActiveStatus(ActiveStatusData);

            //Click on the save button
            SaveButton.Click();

            //Implicit wait
            Wait.wait(1, driver);
        }