示例#1
0
        internal void EditShareSkill()
        {
            //Enabling the Share Skill Button
            ShareSkillButton.Click();

            //Navigating to the Share Skill Page
            GlobalDefinitions.driver.Navigate().GoToUrl("http://localhost:5000/Home/ServiceListing");

            //Populate the Excel Sheet from ShareSkillDetails sheet
            GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkillDetails");
            GlobalDefinitions.wait(5);

            //Reading the Excel file-Title
            Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title"));
            GlobalDefinitions.wait(5);

            //Reading the Excel file-Description
            Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description"));
            GlobalDefinitions.wait(5);

            //Selecting the Category Dropdown
            SelectElement categoryDropdown = new SelectElement(CategoryDropDown);

            //Initializing the Expected Category for Assertion/ Reading the Excel File-Category
            var expectedCategory = GlobalDefinitions.ExcelLib.ReadData(2, "Category");

            categoryDropdown.SelectByText(expectedCategory);
            GlobalDefinitions.wait(5);

            //Selecting the Subcategory Dropdown
            SelectElement subCategorydropdown = new SelectElement(SubCategoryDropDown);

            //Reading the excel file - Subcategory
            subCategorydropdown.SelectByText(GlobalDefinitions.ExcelLib.ReadData(2, "Select Subcategory"));
            GlobalDefinitions.wait(5);


            //Clearing the existing tags before sending new Tags/Reading the Excel File - Tags
            Tags.Clear();
            Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags"));
            Tags.SendKeys(Environment.NewLine);

            //Clicking the Service Type radio button
            HourlyBasisService.Click();
            OneOffService.Click();

            //Clicking the Location Type radio button
            OnSiteLocationType.Click();
            OnlineLocationType.Click();

            //Clicking the Skill Trade radio button (Skill-exchange)
            SkillExchangeBtn.Click();
            GlobalDefinitions.wait(5);

            //Reading the Excel File - Skill Exchange Tags
            SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill Exchange"));

            //Clicking the Skill Trade radio button (Credit)
            CreditOptionBtn.Click();
            GlobalDefinitions.wait(5);

            //Reading the Excel File - Credit Charge
            CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit"));

            //Clicking the Active radio button
            ActiveOption.Click();
            HiddenOption.Click();
            GlobalDefinitions.wait(10);


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

            //Reading the excel file for StartDate
            StartDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Start Date"));

            //Reading the excel file for EndDate
            EndDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "End Date"));


            //Using a for loop for reading the excel file including the days[Checkboxes]
            for (var i = 2; i <= 8; i++)
            {
                //Reading the days checkbox element starting on the 2nd row [i-2]
                AvailableCheckBoxes[i - 2].Click();


                //Readtime = converting the string format to Date time format (see GlobalDefinitions changes)
                var excelStartTime = GlobalDefinitions.ExcelLib.ReadTime(i, "Start Time");

                //passing the value of excelStartTime as ex: (0700am) since the system is not accepting spaces
                var startTime = excelStartTime.ToString("hhmmtt");


                //Readtime = converting the string format to Date time format (see GlobalDefinitions changes)
                var excelEndTime = GlobalDefinitions.ExcelLib.ReadTime(i, "End Time");
                var endTime      = excelEndTime.ToString("hhmmtt");

                //Reading data from excel file starting on the 2nd row
                StartTimes[i - 2].SendKeys(startTime);
                EndTimes[i - 2].SendKeys(endTime);
            }

            //Saving Skills
            Save.Click();
            GlobalDefinitions.wait(20);

            //Assertion if the actual category is the same as the expected category
            var actualCategory = GlobalDefinitions.driver.FindElement(By.XPath($"//td[normalize-space()='{expectedCategory}']")).Text;

            Assert.AreEqual(actualCategory, expectedCategory);
        }
示例#2
0
        internal void EditShareSkill()
        {
            //Populate the Excel sheet
            Global.GlobalDefinitions.ExcelLib.PopulateInCollection(Global.Base.ExcelPath, "ShareSkill");
            int excelRowToRead = 3;

            Title.Clear();
            Title.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "Title"));

            //Click on Description
            Description.Clear();
            Description.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "Description"));

            //Select A Category
            CategoryDropDown.Click();
            String categoryValue = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "Category");
            IList <IWebElement> CategoriesDropDownList = CategoryDropDown.FindElements(By.XPath("//option"));
            int DpListCount = CategoriesDropDownList.Count;

            for (int i = 0; i < DpListCount; i++)
            {
                if (CategoriesDropDownList[i].Text == categoryValue)
                {
                    CategoriesDropDownList[i].Click();
                }
            }

            //Select Sub Category
            Thread.Sleep(1000);
            IWebElement SubCategorySelection = Global.GlobalDefinitions.driver.FindElement(By.Name("subcategoryId"));

            SubCategorySelection.Click();
            String SubCategoryValue = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "SubCategory");
            IList <IWebElement> SubCategoriesDropDownList = SubCategorySelection.FindElements(By.XPath("//option"));
            int SbDpListCount = SubCategoriesDropDownList.Count;

            for (int i = 0; i < SbDpListCount; i++)
            {
                if (SubCategoriesDropDownList[i].Text == SubCategoryValue)
                {
                    SubCategoriesDropDownList[i].Click();
                }
            }

            //Clear and Add Tags
            IWebElement         tagsInputBox  = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[4]/div[2]/div"));
            IList <IWebElement> RemoveButtons = tagsInputBox.FindElements(By.ClassName("ReactTags__remove"));

            foreach (IWebElement element in RemoveButtons)
            {
                element.Click();
            }
            Tags.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "Tag"));
            Tags.SendKeys(Keys.Enter);

            //Select Service Type
            String ServiceType = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "Service Type");

            if (ServiceType.Equals("Hourly basis Service"))
            {
                HourlyServiceType.Click();
            }

            else if (ServiceType.Equals("One-off Service"))
            {
                OneOffServiceType.Click();
            }

            //Select Location Type
            String LocatioType = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "Location Type");

            if (LocatioType.Equals("On-site"))
            {
                OnSiteLocationType.Click();
            }

            else if (OnSiteLocationType.Equals("Online"))
            {
                OnlineLocationType.Click();
            }

            //Select Available Start Date
            IWebElement AvailableStartDateInput = AvailabilityForm.FindElement(By.Name("startDate"));

            AvailableStartDateInput.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "AvailableStartDate"));

            //Select Available End Date
            IWebElement AvailableEndDateInput = AvailabilityForm.FindElement(By.Name("endDate"));

            AvailableEndDateInput.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "AvailableEndDate"));

            String[] WeekDays = new String[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };

            //Cleared Selected Checkboxes
            IList <IWebElement> AvailableCheckBoxes = AvailabilityForm.FindElements(By.Name("Available"));

            foreach (IWebElement element in AvailableCheckBoxes)
            {
                if (element.Selected)
                {
                    element.Click();
                }
            }

            //Select Check boxes based on data
            String         AvailableDaysValue = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "AvailableDays");
            IList <String> AvailableDays      = AvailableDaysValue.Split(',');

            for (int i = 0; i < WeekDays.Count(); i++)
            {
                if (AvailableDays.Contains(WeekDays[i]))
                {
                    AvailableCheckBoxes[i].Click();
                }
            }

            //Set Start times
            IList <IWebElement> AvailableStartTimeInputs = AvailabilityForm.FindElements(By.Name("StartTime"));
            String         AvailableStartTimesValue      = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "AvailableStartTimes");
            IList <String> AvailableStartTimes           = AvailableStartTimesValue.Split(',');

            for (int i = 0; i < AvailableStartTimes.Count(); i++)
            {
                IList <String> startTimeInfo  = AvailableStartTimes[i].Split(':');
                String         startTimeDay   = startTimeInfo[0];
                String         startTimeValue = startTimeInfo[1];
                int            indexOfDay     = Array.IndexOf(WeekDays, startTimeDay);
                AvailableStartTimeInputs[indexOfDay].SendKeys(startTimeValue);
            }

            //Set End times
            IList <IWebElement> AvailableEndTimeInputs = AvailabilityForm.FindElements(By.Name("EndTime"));
            String         AvailableEndTimesValue      = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "AvailableEndTimes");
            IList <String> AvailableEndTimes           = AvailableEndTimesValue.Split(',');

            for (int i = 0; i < AvailableEndTimes.Count(); i++)
            {
                IList <String> endTimeInfo  = AvailableEndTimes[i].Split(':');
                String         endTimeDay   = endTimeInfo[0];
                String         endTimeValue = endTimeInfo[1];
                int            indexOfDay   = Array.IndexOf(WeekDays, endTimeDay);
                AvailableEndTimeInputs[indexOfDay].SendKeys(endTimeValue);
            }

            //Select Skill Exchange Type
            String SkillTradeType = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "SkillTradeType");

            if (SkillTradeType.Equals("Skill-exchange"))
            {
                SkillExchangeType.Click();

                //Clear and Add Tags
                IWebElement         SkillTagsInputBox = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[8]/div[4]/div/div"));
                IList <IWebElement> CrossButtons      = SkillTagsInputBox.FindElements(By.ClassName("ReactTags__remove"));
                foreach (IWebElement element in CrossButtons)
                {
                    element.Click();
                }
                SkillExchangeTag.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "SkillExchangeTab"));
                SkillExchangeTag.SendKeys(Keys.Enter);
            }

            else if (SkillTradeType.Equals("Credit"))
            {
                CreditsType.Click();
                CreditAmount.Clear();
                CreditAmount.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "CreditsAmount"));
            }

            //Select Active Status Button
            String ActiveType = Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "ActiveType");

            if (SkillTradeType.Equals("Active"))
            {
                ActiveButton.Click();
            }
            else if (SkillTradeType.Equals("Hidden"))
            {
                HiddenButton.Click();
            }

            //Click on Save Button
            SaveButton.Click();
            Thread.Sleep(3000);

            //Verify
            IWebElement         listingTable = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/table"));
            IList <IWebElement> tableRows    = listingTable.FindElements(By.TagName("tr"));

            Boolean isListingEdited = false;

            for (int i = 0; i <= tableRows.Count; i++)
            {
                IWebElement row = tableRows[i];
                if (row.Text.Contains(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "Title")) && row.Text.Contains(Global.GlobalDefinitions.ExcelLib.ReadData(excelRowToRead, "Description")))
                {
                    isListingEdited = true;
                    break;
                }
            }
            if (isListingEdited == true)
            {
                Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Edit Skill test Successful");
            }
            else
            {
                Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Edit Skill test Failed");
            }
        }