/// <summary>
        /// Saves the service record details given in the excel sheet data for given number of records <paramref name="RecordNo"/> and
        /// returns data if record successfully saved
        /// </summary>
        /// <returns>
        /// If the record exists in the table
        /// </returns>
        /// <param name="RecordNo">The number of records to be saved as int Value </param>
        internal string SaveNew(int RecordNo)
        {
            //Populate the Excel Sheet
            GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ServiceListing");
            Thread.Sleep(1000);

            //Record Row No Starts with 2 in the DataSet
            RecordNo += 2;

            //Enter Title
            string TitleInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "Title");

            Title.SendKeys(TitleInput);

            //Enter Description
            string DescriptionInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "Description");

            Description.SendKeys(DescriptionInput);

            //Select Category
            string CategoryInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "Category");

            if (!("" == CategoryInput || null == CategoryInput))
            {
                ValidateCategory(CategoryInput);
                var selectCategory = new SelectElement(Category);
                selectCategory.SelectByText(CategoryInput);
                Thread.Sleep(1000);
            }

            //Select SubCategory
            string SubCategoryInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "SubCategory");

            if (!("" == SubCategoryInput || null == SubCategoryInput))
            {
                ValidateSubCategory(SubCategoryInput);
                var selectSubCatElement = new SelectElement(SubCategory);
                selectSubCatElement.SelectByText(SubCategoryInput);
                Thread.Sleep(500);
            }


            //Add tags
            //Multiple Tag values are supported using ',' seperater under the Tags column
            var TagsInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "Tags");

            string[] Inputs = TagsInput.Split(',');

            foreach (var tag in Inputs)
            {
                Tags.SendKeys(tag);
                Tags.SendKeys(Keys.Enter);
                Thread.Sleep(200);
            }

            //Select Service Type
            var ServiceTypeInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "ServiceType");

            if (!("" == ServiceTypeInput || null == ServiceTypeInput))
            {
                ValidateServiceType(ServiceTypeInput);
                if (ServiceTypeInput == "Hourly basis service")
                {
                    ServiceTypeHourlyBased.Click();
                }
                else
                {
                    ServiceTypeOneOff.Click();
                }
                Thread.Sleep(500);
            }


            //Select Location Type
            var LocationTypeInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "LocationType");

            if (!("" == LocationTypeInput || null == LocationTypeInput))
            {
                ValidateLocationType(LocationTypeInput);

                if (LocationTypeInput == "On-site")
                {
                    LocationTypeOnSite.Click();
                }
                else
                {
                    LocationTypeOnline.Click();
                }
                Thread.Sleep(500);
            }


            //Enter available days
            var StartDateInput  = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "StartDate");
            var StartMonthInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "StartMonth");
            var StartYearInput  = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "StartYear");
            var EndDateInput    = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "EndDate");
            var EndMonthInput   = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "EndMonth");
            var EndYearInput    = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "EndYear");
            var AvailDaysInput  = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "AvailableDays");
            var StartTimeInput  = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "StartTime");
            var EndTimeInput    = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "EndTime");

            if (StartDateInput != "")
            {
                StartDate.SendKeys(StartMonthInput);
                Thread.Sleep(200);
                StartDate.SendKeys(StartDateInput);
                Thread.Sleep(200);
                StartDate.SendKeys(StartYearInput);
                Thread.Sleep(500);
            }
            if (EndDateInput != "")
            {
                EndDate.SendKeys(EndMonthInput);
                Thread.Sleep(200);
                EndDate.SendKeys(EndDateInput);
                Thread.Sleep(200);
                EndDate.SendKeys(EndYearInput);
                Thread.Sleep(500);
            }

            string[] Days = AvailDaysInput.Split(',');

            foreach (var AvailDay in Days)
            {
                switch (AvailDay)
                {
                case "Sun":
                    SunCheckBox.Click();
                    SunStartTime.SendKeys(StartTimeInput);
                    SunEndTime.SendKeys(EndTimeInput);
                    break;

                case "Mon":
                    MonCheckBox.Click();
                    MonStartTime.SendKeys(StartTimeInput);
                    MonEndTime.SendKeys(EndTimeInput);
                    break;

                case "Tue":
                    TueCheckBox.Click();
                    TueStartTime.SendKeys(StartTimeInput);
                    TueEndTime.SendKeys(EndTimeInput);
                    break;

                case "Wed":
                    WedCheckBox.Click();
                    WedStartTime.SendKeys(StartTimeInput);
                    WedEndTime.SendKeys(EndTimeInput);
                    break;

                case "Thur":
                    ThursCheckBox.Click();
                    ThursStartTime.SendKeys(StartTimeInput);
                    ThursEndTime.SendKeys(EndTimeInput);
                    break;

                case "Fri":
                    FriCheckBox.Click();
                    FriStartTime.SendKeys(StartTimeInput);
                    FriEndTime.SendKeys(EndTimeInput);
                    break;

                case "Sat":
                    SatCheckBox.Click();
                    SatStartTime.SendKeys(StartTimeInput);
                    SatEndTime.SendKeys(EndTimeInput);
                    break;
                }
                Thread.Sleep(300);
            }

            //Select Skill Trade
            var SkillTradeInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "SkillTrade");

            if (!("" == SkillTradeInput || null == SkillTradeInput))
            {
                ValidateSkillTradeOption(SkillTradeInput);

                if (SkillTradeInput == "Skill-exchange")
                {
                    SkillTradeExchange.Click();
                    Thread.Sleep(500);

                    //Add Skill Exchange Tags
                    //Multiple Tag values are supported using ',' seperater under the Skill Exchange Tags column
                    var SkillExTagsInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "SkillExchangeTags");

                    if (SkillExTagsInput != "")
                    {
                        string[] SkillExTags = SkillExTagsInput.Split(',');

                        foreach (var skill in SkillExTags)
                        {
                            SkillExchangeTags.SendKeys(skill);
                            SkillExchangeTags.SendKeys(Keys.Enter);
                            Thread.Sleep(300);
                        }
                    }
                }
                else
                {
                    SkillTradeCredit.Click();
                    Thread.Sleep(500);

                    //Add Skill Trade Credit Amount
                    var SkillCreditAmountInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "SkillTradeCredit");
                    Thread.Sleep(500);

                    if (SkillCreditAmountInput != "")
                    {
                        ChargeAmount.SendKeys(SkillCreditAmountInput);
                        Thread.Sleep(500);
                    }
                }
            }

            //Add Work Samples

            var WorkSampleInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "WorkSamples");

            if (WorkSampleInput != "")
            {
                WorkSampleUpload.Click();

                AutoItX3 autoItX3 = new AutoItX3();
                autoItX3.WinActivate("File Upload");
                Thread.Sleep(200);
                autoItX3.Send(@WorkSampleInput);
                Thread.Sleep(500);
                autoItX3.Send("{ENTER}");
                Thread.Sleep(1000);
            }

            //Select Active Status
            var ActiveInput = GlobalDefinitions.ExcelLib.ReadData(RecordNo, "Active");

            if (!("" == ActiveInput || null == ActiveInput))
            {
                ValidateActiveOption(ActiveInput);
                if (ActiveInput == "Active")
                {
                    IsActive.Click();
                }
                else
                {
                    IsHidden.Click();
                }
                Thread.Sleep(500);
            }

            //Save Service Details
            Save.Click();
            Thread.Sleep(2000);

            //Check the saved record in the listings
            ManageListing manageListing = new ManageListing();
            bool          IsExist       = manageListing.ValidateRecordInTable(CategoryInput, TitleInput);

            return(IsExist.ToString());
        }
Esempio n. 2
0
        //[FindsBy(How = How.XPath, Using = "//*[@id='listing-management-section']/div[2]/div[1]/table/tbody/tr/td[4]")]
        //private IWebElement ItemToDelete { get; set; }

        //[FindsBy(How = How.XPath, Using = "")]
        //private IWebElement  { get; set; }

        //[FindsBy(How = How.XPath, Using = "")]
        //private IWebElement  { get; set; }



        #endregion

        internal void AddSkill()
        {
            //Populate the Excel sheet
            Global.GlobalDefinitions.ExcelLib.PopulateInCollection(Global.Base.ExcelPath, "Skill");

            ShareSkillBtn.Click();
            Global.GlobalDefinitions.wait(5);

            TitleTextbox.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Title"));

            DescriptionTextbox.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Description"));

            CategoryDropdown.Click();
            var category      = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[3]/div[2]/div/div/select"));
            var selectElement = new SelectElement(category);

            selectElement.SelectByIndex(3);

            SubcategoryDropdown.Click();
            var subcategory    = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[3]/div[2]/div/div[2]/div[1]/select"));
            var selectElement1 = new SelectElement(subcategory);

            selectElement1.SelectByIndex(3);

            TagsTextbox.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Tags"));
            TagsTextbox.SendKeys(Keys.Enter);

            TagsTextbox1.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(3, "Tags"));
            TagsTextbox1.SendKeys(Keys.Enter);

            OneoffService.Click();
            Thread.Sleep(500);
            HourlyService.Click();
            Thread.Sleep(500);

            OnSite.Click();
            Thread.Sleep(500);
            Online.Click();


            StartdateTextbox.Click();
            StartdateTextbox.SendKeys(DateTime.Now.AddDays(5).ToString("dd/MM/yyyy"));

            EnddateTextbox.Click();
            EnddateTextbox.SendKeys(DateTime.Now.AddMonths(1).ToString("dd/MM/yyyy"));

            SunCheckBox.Click();
            SunStartTime.Click();
            SunStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartHour"));
            SunStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartMinutes"));
            SunStartTime.SendKeys(Keys.Up);
            SunEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndHour"));
            SunEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndMinutes"));
            SunEndTime.SendKeys(Keys.ArrowDown);

            MonCheckBox.Click();
            MonStartTime.Click();
            MonStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartHour"));
            MonStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartMinutes"));
            MonStartTime.SendKeys(Keys.Up);
            MonEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndHour"));
            MonEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndMinutes"));
            MonEndTime.SendKeys(Keys.ArrowDown);

            TueCheckBox.Click();
            TueStartTime.Click();
            TueStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartHour"));
            TueStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartMinutes"));
            TueStartTime.SendKeys(Keys.Up);
            TueEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndHour"));
            TueEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndMinutes"));
            TueEndTime.SendKeys(Keys.ArrowDown);

            WedCheckBox.Click();
            WedStartTime.Click();
            WedStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartHour"));
            WedStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartMinutes"));
            WedStartTime.SendKeys(Keys.Up);
            WedEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndHour"));
            WedEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndMinutes"));
            WedEndTime.SendKeys(Keys.ArrowDown);

            ThuCheckBox.Click();
            ThuStartTime.Click();
            ThuStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartHour"));
            ThuStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartMinutes"));
            ThuStartTime.SendKeys(Keys.Up);
            ThuEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndHour"));
            ThuEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndMinutes"));
            ThuEndTime.SendKeys(Keys.ArrowDown);

            FriCheckBox.Click();
            FriStartTime.Click();
            FriStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartHour"));
            FriStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartMinutes"));
            FriStartTime.SendKeys(Keys.Up);
            FriEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndHour"));
            FriEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndMinutes"));
            FriEndTime.SendKeys(Keys.ArrowDown);

            SatCheckBox.Click();
            SatStartTime.Click();
            SatStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartHour"));
            SatStartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "StartMinutes"));
            SatStartTime.SendKeys(Keys.Up);
            SatEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndHour"));
            SatEndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "EndMinutes"));
            SatEndTime.SendKeys(Keys.ArrowDown);

            SkillExchangeButton.Click();
            SkillExchangeTag.Click();
            SkillExchangeTag.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "SkillToExchange"));
            SkillExchangeTag.SendKeys(Keys.Enter);

            CreditButton.Click();
            CreditAmount.Click();
            CreditAmount.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "CreditAmount"));

            PlusCircleIcon.Click();


            //Upload file
            AutoItX3 autoIt = new AutoItX3();

            autoIt.WinActivate("Open");
            autoIt.Send(@"C:\Users\Nemesis\Pictures\TanslatePix\zodiac.jpg");
            Thread.Sleep(500);
            autoIt.Send("{ENTER}");

            Thread.Sleep(500);
            PlusCircleIcon.Click();

            AutoItX3 autoIt1 = new AutoItX3();

            autoIt1.WinActivate("Open");
            Thread.Sleep(500);
            autoIt1.Send(@"C:\Users\Nemesis\Pictures\TanslatePix\doggie.jpg");
            Thread.Sleep(500);
            autoIt1.Send("{ENTER}");

            Thread.Sleep(500);
            RemoveItem.Click();

            HiddenRadioButton.Click();
            Thread.Sleep(1000);
            ActiveRadioButton.Click();

            SaveButton.Click();

            Global.GlobalDefinitions.wait(5);


            //Add Skill Verification
            ManageListingsTab.Click();

            Global.GlobalDefinitions.wait(5);

            string ExpectedText = Global.GlobalDefinitions.ExcelLib.ReadData(2, "Description");
            string ActualText   = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/table/tbody/tr/td[4]")).Text;

            if (ExpectedText.Equals(ActualText))
            {
                Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Add Skill Successful");
                String img = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "AddSkill_Pass");
                test.Log(LogStatus.Info, "Image example: " + img);
            }
            else
            {
                Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Add Skill UnSuccessful");
                String img1 = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "AddSkill_Fail");
                test.Log(LogStatus.Info, "Image example: " + img1);
            }
        }