コード例 #1
0
        /// <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());
        }
コード例 #2
0
        public void AddNewShareSkill()
        {
            #region Navigate to Share Skills Page

            // Click on Share Skills Page
            ShareSkills.Click();
            Thread.Sleep(1000);

            //Populate the excel data
            GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkill");

            // Enter Title
            Title.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Title"));
            Base.test.Log(LogStatus.Info, "Title has been successfully entered");

            //Enter description
            Description.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Description"));
            Base.test.Log(LogStatus.Info, "Description has been successfully entered");

            //click on category dropdown menu
            Thread.Sleep(500);
            Category.Click();
            Thread.Sleep(1000);


            //Select the category
            ProgrammingandTech.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Category"));
            Thread.Sleep(1000);


            //Click on subcatogory drop down option
            Thread.Sleep(1000);
            SubCategory.Click();

            //Select the Sub-Category option
            SubCategory.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Subcategory"));
            SubCategory.SendKeys(Keys.Enter);
            Base.test.Log(LogStatus.Info, "SubCategory has been successfully entered");
            QA.Click();


            //Enter Tags
            Tags.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Tags"));
            Tags.SendKeys(Keys.Enter);
            Base.test.Log(LogStatus.Info, "TagName has been successfully entered");

            //Select service type
            //ServiceTypeHourly.Click();

            if (GlobalDefinitions.ExcelLib.ReadData(2, "Service Type") == "Hourly basis service")
            {
                ServiceTypeHourly.Click();
            }
            else if (GlobalDefinitions.ExcelLib.ReadData(2, "Service Type") == "One-off service")
            {
                ServiceTypeOneOff.Click();
            }

            //Select Location Type
            //LocationTypeOnline.Click();
            if (GlobalDefinitions.ExcelLib.ReadData(2, "Location Type") == "Online")
            {
                LocationTypeOnline.Click();
            }
            else if (GlobalDefinitions.ExcelLib.ReadData(2, "Location Type") == "On-site")
            {
                LocationTypeOnsite.Click();
            }



            //Click the start date
            StartDate.Click();
            Thread.Sleep(500);

            //Select the date
            Thread.Sleep(500);
            StartDate.SendKeys(Keys.Backspace);
            StartDate.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Start Date"));

            //Select the end Date
            Thread.Sleep(1000);
            EndDate.SendKeys(Keys.Backspace);
            EndDate.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "End Date"));

            //Select the Days available
            selectDays.Click();
            Thread.Sleep(500);

            //Select starttime
            Thread.Sleep(1000);
            StartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Start Time"));

            //Select EndTime
            Thread.Sleep(1000);
            EndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "End Time"));

            //Select Skill Trade
            Credit.Click();
            Thread.Sleep(500);
            if (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade") == "Skill-exchange")
            {
                RequiredSkills.Click();
                RequiredSkills.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade"));
                RequiredSkills.SendKeys(Keys.Enter);
            }
            else if (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade") == "Credit")
            {
                CreditAmount.Click();
                CreditAmount.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Credit Amount"));
                CreditAmount.SendKeys(Keys.Enter);

                //Enter credit amount
                // CreditAmount.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Credit Amount"));

                //Select the stats
                // StatusActive.Click();
                //Thread.Sleep(500);
                if (GlobalDefinitions.ExcelLib.ReadData(2, "Status") == "Active")
                {
                    StatusActive.Click();
                }
                else if (GlobalDefinitions.ExcelLib.ReadData(2, "Status") == "Hidden")
                {
                    StatusHidden.Click();
                }

                //Save the Share Skill
                Thread.Sleep(500);
                SaveShareSkills.Click();
                Thread.Sleep(500);


                //Verify if newShared skill is saved
                Thread.Sleep(3000);
                string ShareSkillSucess = Global.GlobalDefinitions.driver.FindElement(By.CssSelector("#listing-management-section > div:nth-child(3) > div:nth-child(2) > table > thead > tr > th:nth-child(1)")).Text;

                if (ShareSkillSucess == "Image")
                {
                    Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Saved Skill Successful");
                }
                else
                {
                    Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Saving Skill Unsuccessful");
                }
            }
        }
コード例 #3
0
        //public void AddNewShareSkill()

        internal void AddNewSkill()
        {
            {
                #region Enter the deatils

                //Click on Share Skill button
                Thread.Sleep(1000);
                ShareSkills.Click();
                Thread.Sleep(1000);

                //Populate the excel data
                GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkills");

                // Enter Title
                Title.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Title"));
                Base.test.Log(LogStatus.Info, "Title has been successfully entered");

                //Enter description
                Description.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Description"));
                Base.test.Log(LogStatus.Info, "Description has been successfully entered");

                //click on category dropdown menu
                Thread.Sleep(500);
                Category.Click();
                Thread.Sleep(1000);


                //Select the category
                Thread.Sleep(500);
                ProgrammingandTech.Click();
                Thread.Sleep(500);



                //Click on subcatogory drop down option
                Thread.Sleep(1000);
                SubCategory.Click();

                //Select the Sub-Category option
                Thread.Sleep(500);
                QA.Click();
                Thread.Sleep(500);

                //Enter Tags
                Tags.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Tags"));
                Tags.SendKeys(Keys.Enter);
                Base.test.Log(LogStatus.Info, "TagName has been successfully entered");

                //Select service type
                //ServiceTypeHourly.Click();

                if (GlobalDefinitions.ExcelLib.ReadData(2, "Service Type") == "Hourly basis service")
                {
                    ServiceTypeHourly.Click();
                }
                else if (GlobalDefinitions.ExcelLib.ReadData(2, "Service Type") == "One-off service")
                {
                    ServiceTypeOneOff.Click();
                }

                //Select Location Type
                //LocationTypeOnline.Click();
                if (GlobalDefinitions.ExcelLib.ReadData(2, "Location Type") == "Online")
                {
                    LocationTypeOnline.Click();
                }
                else if (GlobalDefinitions.ExcelLib.ReadData(2, "Location Type") == "On-site")
                {
                    LocationTypeOnsite.Click();
                }



                //Select the date
                Thread.Sleep(1000);
                StartDate.SendKeys(Keys.Delete);
                Thread.Sleep(2000);

                StartDate.SendKeys(Keys.Backspace);
                Thread.Sleep(1000);
                StartDate.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Start Date"));
                Console.WriteLine("Start date is : " + GlobalDefinitions.ExcelLib.ReadData(2, "Start Date"));

                //StartDate.SendKeys("25-07-2019");

                ////Select the end Date
                //EndDate.SendKeys("21-08-2019");
                Thread.Sleep(1000);
                EndDate.SendKeys(Keys.Delete);

                EndDate.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "End Date"));
                Thread.Sleep(2000);
                Console.WriteLine("End date is : " + GlobalDefinitions.ExcelLib.ReadData(2, "End Date"));
                //Select the Days available


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

                //Select starttime
                Thread.Sleep(1000);
                StartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Start Time"));
                Thread.Sleep(2000);
                Console.WriteLine("Start Time is : " + GlobalDefinitions.ExcelLib.ReadData(2, "Start Time"));
                //StartTime.SendKeys("12:00PM");

                //Select EndTime
                Thread.Sleep(1000);
                EndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "End Time"));
                Console.WriteLine("End Time is : " + GlobalDefinitions.ExcelLib.ReadData(2, "End Time"));
                //EndTime.SendKeys("3:00PM");

                //Select Skill Trade
                Credit.Click();
                Thread.Sleep(500);
                if (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade") == "Skill-exchange")
                {
                    Skillstrade.Click();
                    Skillstrade.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade"));
                    Skillstrade.SendKeys(Keys.Enter);
                }
                else if (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade") == "Credit")
                {
                    CreditAmount.Click();
                    CreditAmount.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Credit Amount"));
                    CreditAmount.SendKeys(Keys.Enter);

                    //Enter credit amount
                    // CreditAmount.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Credit Amount"));

                    //Select the stats
                    // StatusActive.Click();
                    //Thread.Sleep(500);

                    //select Work Sample
                    Sample.Click();

                    AutoItX3 fileupload = new AutoItX3();
                    fileupload.WinActivate("Open");
                    Thread.Sleep(3000);
                    fileupload.Send(@"C:\Users\harpr\OneDrive\Documents\Testing.jpg");
                    Thread.Sleep(1000);
                    fileupload.Send("{ENTER}");


                    //Thread.Sleep(4000);



                    Console.WriteLine("File has been uploaded successfully");

                    if (GlobalDefinitions.ExcelLib.ReadData(2, "Status") == "Active")
                    {
                        Active.Click();
                    }
                    else if (GlobalDefinitions.ExcelLib.ReadData(2, "Status") == "Hidden")
                    {
                        Hidden.Click();
                    }

                    //Save the Share Skill
                    Thread.Sleep(500);
                    Save.Click();
                    Thread.Sleep(500);


                    //Verify if newShared skill is saved
                    Thread.Sleep(3000);
                    string ShareSkillSucess = Global.GlobalDefinitions.driver.FindElement(By.XPath("//th[contains(text(),'Image')]")).Text;

                    if (ShareSkillSucess == "Image")
                    {
                        Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Saved Skill Successful");
                    }
                    else
                    {
                        Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Saving Skill Unsuccessful");
                    }
                }
            }
            #endregion
        }