示例#1
0
        internal void UploadSample(int DataRow)
        {
            //Click on Upload Sample File
            WorkSample.Click();

            //Uses AutoIt to handle the file explorer
            AutoIt.UploadFile(GlobalDefinitions.ReadData(DataRow, "FilePath"));
        }
示例#2
0
        internal void EditShareSkill()
        {
            GlobalDefinitions.ExcelLib.PopulateInCollection(@"C:\Users\Rammy\Desktop\marsframework\MarsFramework\ExcelData\TestDataShareSkill.xlsx", "ShareSkill");
            GlobalDefinitions.wait(30);

            //Click on ShareSkill button
            ShareSkillButton.Click();

            //Wait
            GlobalDefinitions.wait(30);

            //Enter data in Title textbox
            Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "Title"));
            string TitleTextbox = Title.GetAttribute("Value");

            if (TitleTextbox.Length == 0)
            {
                Assert.IsEmpty("Title");
            }

            //Enter data in Description textbox
            Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "Description"));
            Assert.That(Description.Text, Is.EqualTo(GlobalDefinitions.ExcelLib.ReadData(3, "Description")));

            CategoryDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "Category"));
            CategoryDropDown.Click();

            SubCategoryDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "SubCategory"));
            SubCategoryDropDown.Click();

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

            //Click on Hourly basis service or One-off service
            if (GlobalDefinitions.ExcelLib.ReadData(3, "Service Type") == "Hourly basis service")
            {
                Hourlybasisservice.Click();
            }
            else if (GlobalDefinitions.ExcelLib.ReadData(3, "Service Type") == "One-off service")
            {
                OneOffservice.Click();
            }

            //Click on On-site or Online
            if (GlobalDefinitions.ExcelLib.ReadData(3, "Location Type") == "On-site")
            {
                OnSite.Click();
            }
            else if (GlobalDefinitions.ExcelLib.ReadData(3, "Location Type") == "Online")
            {
                Online.Click();
            }

            //Wait
            GlobalDefinitions.wait(60);

            //Convert excel dateformat to C# - Enter data in Staredate
            string dateformat   = "dd / MM / yyyy";
            string sdate        = GlobalDefinitions.ExcelLib.ReadData(3, "Startdate");
            string newStartDate = DateTime.Parse(sdate).ToString(dateformat);

            StartDateDropDown.SendKeys(newStartDate);

            string StartDate = StartDateDropDown.GetAttribute("Value");

            if (StartDate.Length == 0)
            {
                Assert.IsEmpty("Startdate");
            }

            //Convert excel dateformat to C# - Enter data in Enddate
            string edate      = GlobalDefinitions.ExcelLib.ReadData(3, "Enddate");
            string newEndDate = DateTime.Parse(edate).ToString(dateformat);

            EndDateDropDown.SendKeys(newEndDate);

            string EndDate = EndDateDropDown.GetAttribute("Value");

            if (EndDate.Length == 0)
            {
                Assert.IsEmpty("Enddate");
            }

            //Wait
            GlobalDefinitions.wait(60);

            //Click on a day
            Days.Click();

            //Convert excel timeformat to C# - enter data in Starttime
            string timeformat   = "hh:mmtt";
            string stime        = GlobalDefinitions.ExcelLib.ReadData(3, "Starttime");
            string newStartTime = DateTime.Parse(stime).ToString(timeformat);

            StartTimeDropDown.SendKeys(newStartTime);

            string Start = StartTimeDropDown.GetAttribute("Value");

            if (Start.Length == 0)
            {
                Assert.IsEmpty("Starttime");
            }

            //Convert excel timeformat to C# - enter data in Endtime
            string etime      = GlobalDefinitions.ExcelLib.ReadData(3, "Endtime");
            string newEndTime = DateTime.Parse(etime).ToString(timeformat);

            EndTimeDropDown.SendKeys(newEndTime);

            string End = EndTimeDropDown.GetAttribute("Value");

            if (End.Length == 0)
            {
                Assert.IsEmpty("Endtime");
            }

            //Click on Skill-exchange or Credit
            if (GlobalDefinitions.ExcelLib.ReadData(3, "SkillTrade") == "Skill-exchange")
            {
                SkillExchangeOption.Click();
                SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange"));
                SkillExchange.SendKeys(Keys.Enter);
            }
            else if (GlobalDefinitions.ExcelLib.ReadData(3, "SkillTrade") == "Credit")
            {
                CreditOption.Click();
                CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit"));
            }


            //Click on Active or Hidden
            ActiveOption.Click();
            if (GlobalDefinitions.ExcelLib.ReadData(3, "Active") == "Active")
            {
                ActiveOption.Click();
            }
            else if (GlobalDefinitions.ExcelLib.ReadData(3, "Active") == "Hidden")
            {
                HiddenOption.Click();
            }

            //Upload a file
            WorkSample.Click();
            GlobalDefinitions.wait(20);
            string path = GlobalDefinitions.ExcelLib.ReadData(3, "WorkSample");

            AutoItX.WinActivate("File Upload");

            //Wait
            GlobalDefinitions.wait(60);

            AutoItX.Send(path);
            AutoItX.Send("{ENTER}");

            Save.Click();

            Assert.That(ManageTitle.Text, Is.EqualTo("Voice Actor"));
        }
示例#3
0
        internal void EditShareSkill(IWebDriver driver)
        {
            CommomDriver.Wait(2000);

            //Click on ShareSkill Button
            ShareSkillBtn.Click();

            //Wait untill driver find title text Field
            CommomDriver.WaitForVisibility(driver, "Name", "title", 2);

            //populate login page data collection
            ExcelLibHelpers.PopulateInCollection(MarsResource.ExcelPath, "EditShareSkill");

            //Give a Title
            Title.SendKeys(ExcelLibHelpers.ReadData(2, "Title"));

            //Give a Description
            Description.SendKeys(ExcelLibHelpers.ReadData(2, "Description"));

            //select one of the option from Category
            Category.SendKeys(ExcelLibHelpers.ReadData(2, "Category"));

            ////Select SubCategory Option
            SubCategory.SendKeys(ExcelLibHelpers.ReadData(2, "Sub Category"));

            //give input in Tag TextField
            Tag.SendKeys(ExcelLibHelpers.ReadData(2, "Tag") + Keys.Enter);
            Tag.SendKeys(ExcelLibHelpers.ReadData(3, "Tag") + Keys.Enter);

            //choose Radio button option
            ServiceType.Click();

            //Choose Location
            Location.Click();

            //Give StartDate
            StartDate.SendKeys(ExcelLibHelpers.ReadData(2, "Start Date"));

            //Give EndDate
            EndDate.SendKeys(ExcelLibHelpers.ReadData(2, "End Date"));

            for (int i = 2; i < 9; i++)
            {
                for (int j = 2; j < 9; j++)
                {
                    IWebElement SatrtTime = driver.FindElement(By.XPath("//div[" + i + "]/div[2]/input"));
                    IWebElement EndTime   = driver.FindElement(By.XPath("//div[" + j + "]/div[3]/input"));
                    if (i == 2 && j == 2)
                    {
                        SatrtTime.SendKeys(ExcelLibHelpers.ReadData(2, "Start Time"));
                        EndTime.SendKeys(ExcelLibHelpers.ReadData(2, "End Time"));
                    }
                    if (i == 3 && j == 3)
                    {
                        SatrtTime.SendKeys(ExcelLibHelpers.ReadData(3, "Start Time"));
                        EndTime.SendKeys(ExcelLibHelpers.ReadData(3, "End Time"));
                    }
                    if (i == 4 && j == 4)
                    {
                        SatrtTime.SendKeys(ExcelLibHelpers.ReadData(4, "Start Time"));
                        EndTime.SendKeys(ExcelLibHelpers.ReadData(4, "End Time"));
                    }
                    if (i == 5 && j == 5)
                    {
                        SatrtTime.SendKeys(ExcelLibHelpers.ReadData(5, "Start Time"));
                        EndTime.SendKeys(ExcelLibHelpers.ReadData(5, "End Time"));
                    }
                    if (i == 6 && j == 6)
                    {
                        SatrtTime.SendKeys(ExcelLibHelpers.ReadData(6, "Start Time"));
                        EndTime.SendKeys(ExcelLibHelpers.ReadData(6, "End Time"));
                    }
                    if (i == 7 && j == 7)
                    {
                        SatrtTime.SendKeys(ExcelLibHelpers.ReadData(7, "Start Time"));
                        EndTime.SendKeys(ExcelLibHelpers.ReadData(7, "End Time"));
                    }
                    if (i == 8 && j == 8)
                    {
                        SatrtTime.SendKeys(ExcelLibHelpers.ReadData(8, "Start Time"));
                        EndTime.SendKeys(ExcelLibHelpers.ReadData(8, "End Time"));
                    }
                    else
                    {
                        continue;
                    }
                }
            }

            //Click on Share Trade Radio Button
            SkillTrade.Click();

            //give inpute Skill Exchange
            SkillExchange.SendKeys(ExcelLibHelpers.ReadData(2, "Skill Exchange") + Keys.Enter + ExcelLibHelpers.ReadData(3, "Skill Exchange") + Keys.Enter);

            //Click on Work Sample
            WorkSample.Click();

            //Handle the window that not belongs to Browser -AutoIt - see blog for more info
            //below line execute the AutoIT script
            //Create an object for AutoIt
            AutoItX3 autoIt = new AutoItX3();

            //This statement Active the window and perform set of auctions
            autoIt.WinActivate("Open");
            Thread.Sleep(1000);
            //set the path to open the file on browser
            autoIt.Send(@"D:\scrummeeting.png");
            Thread.Sleep(1000);
            //It will click on "Open" button
            autoIt.Send("{ENTER}");

            //click on active radio button
            Active.Click();

            //click on save button
            savebtn.Click();

            CommomDriver.Wait(2);
            //For Assertion- Go to manage list
            ManageList.Click();
            //Get the text from manage list of Title and Category
            String ManageTitle        = TitleofManage.Text;
            String ManageListCategory = CategoryofManage.Text;

            try
            {
                //For Assertion - After Save Skills For varification,
                //Goto manage list page and match Title and Cetegory with Excel Enter Skill
                Assert.AreEqual(ManageTitle, ExcelLibHelpers.ReadData(2, "Title"));
                Assert.AreEqual(ManageListCategory, ExcelLibHelpers.ReadData(2, "Category"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        public void EditSkills()
        {
            //Populate the Excel Sheet
            GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ManageListings");
            Thread.Sleep(4000);

            //Click on ManageListings button
            Thread.Sleep(5000);
            Global.GlobalDefinitions.driver.Navigate().Refresh();
            ML.Click();
            Thread.Sleep(4000);

            while (true)

            {
                var j = 1;

                while (j <= 10)

                {
                    // identify 2nd row of table. Then extact the text and assign to a variable

                    var Category1 = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/table/tbody/tr[" + j + "]/td[2]")).Text;
                    var EditBtn   = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/table/tbody/tr[" + j + "]/td[8]/i[2]"));
                    //compare the text with the expected text. "Graphics & Design"

                    if (Category1 == (Global.GlobalDefinitions.ExcelLib.ReadData(2, "Category1")))

                    {
                        //Click on Edit Button
                        EditBtn.Click();
                        Thread.Sleep(3000);

                        // Adding Title
                        Title.Clear();
                        Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title"));
                        Thread.Sleep(500);

                        //Add Description
                        Description.Clear();
                        Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description"));
                        Thread.Sleep(3000);
                        //SaveBtn.Click();
                        Base.test.Log(LogStatus.Info, " Service Listing updated successfully");

                        //Add Category
                        Thread.Sleep(1500);
                        //Actions action = new Actions(GlobalDefinitions.driver);
                        //action.Click(Category);
                        Category.Click();
                        //action.MoveToElement(Category).Build().Perform();
                        Console.WriteLine("Clicked on the Category");
                        Thread.Sleep(2000);
                        IList <IWebElement> CategoryList = Category.FindElements(By.TagName("option"));
                        int Count = CategoryList.Count;
                        Thread.Sleep(500);
                        for (int i = 0; i < Count; i++)
                        {
                            Console.WriteLine("in");

                            if (CategoryList[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Category").Trim())
                            {
                                Thread.Sleep(1000);
                                CategoryList[i].Click();
                                Base.test.Log(LogStatus.Info, " Category Selected");
                            }
                        }

                        //Add SubCategory
                        SubCategory.Click();
                        Console.WriteLine("Clicked on the SubCategory");
                        Thread.Sleep(2000);
                        IList <IWebElement> SubCategoryList = SubCategory.FindElements(By.TagName("option"));
                        //int count = SubCatogeryList.Count;
                        Thread.Sleep(500);
                        for (int i = 0; i < SubCategoryList.Count; i++)
                        {
                            if (SubCategoryList[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory"))
                            //if (SubCatogeryList[i].Text == " Other".Trim())
                            {
                                Thread.Sleep(1000);
                                SubCategoryList[i].Click();
                                Base.test.Log(LogStatus.Info, " SubCategory Selected");
                            }
                        }


                        // Add Tags
                        Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags"));
                        Base.test.Log(LogStatus.Info, " Service Listing updated successfully");

                        // Select Service Type
                        Thread.Sleep(1000);
                        if (GlobalDefinitions.ExcelLib.ReadData(2, "Service Type") == "One-off service")
                        {
                            ServiceType.Click();
                        }
                        else
                        {
                            Servicetype.Click();
                        }
                        Base.test.Log(LogStatus.Info, "Service type Edited successfully");

                        //Select Location Type
                        Thread.Sleep(1000);
                        if (GlobalDefinitions.ExcelLib.ReadData(2, "Location Type") == "Online")
                        {
                            LocationType.Click();
                        }
                        else
                        {
                            Locationtype.Click();
                        }
                        Base.test.Log(LogStatus.Info, "Location Type Edited successfully");

                        //Monday Check Box Selection
                        Thread.Sleep(2000);
                        Boolean X = MondayCheckBox.Selected;

                        if (X == false)
                        {
                            MondayCheckBox.Click();
                        }

                        MondayStartTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Start Time"));
                        Thread.Sleep(1000);
                        MondayEndTime.Clear();
                        MondayEndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "End Time"));
                        Thread.Sleep(1000);

                        //Tuesday Selection
                        //TuesdayCheckBox.Click();
                        //TuesdayStartTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "Start Time"));
                        //TuesdayEndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "End Time"));

                        //Days selection
                        Thursdaycheckbox.Click();
                        Thread.Sleep(2000);
                        ThursdayStartTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Start Time"));
                        ThursdayEndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "End Time"));

                        //Selecting Skill Trade

                        if (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade") == "Skill-exchange")
                        {
                            SkillTrade.Click();
                        }

                        else
                        {
                            Skilltrade.Click();
                        }
                        Base.test.Log(LogStatus.Info, " Service Listing updated successfully");

                        // Enter Skill Exchange
                        AutoItX3 autoItx = new AutoItX3();
                        SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange"));
                        autoItx.Send("{Enter}");
                        Thread.Sleep(3000);
                        Base.test.Log(LogStatus.Info, " Service Listing updated successfully");

                        //Upload WorkSample
                        Thread.Sleep(4000);
                        WorkSample.Click();
                        Thread.Sleep(1000);
                        AutoItX3 autoit = new AutoItX3();
                        autoit.WinActivate("Open");
                        autoit.Send(@"c:\users\rajesh jasti\Documents\Worksamples.xlsx");
                        Thread.Sleep(5000);
                        autoit.Send("{Enter}");
                        Base.test.Log(LogStatus.Info, "Work Sample Updated successfully");

                        // select Active
                        Thread.Sleep(1000);
                        if (GlobalDefinitions.ExcelLib.ReadData(2, "Active") == "Active")
                        {
                            ActiveBtn.Click();
                        }
                        else
                        {
                            Hidden.Click();
                        }

                        //Click on Save Button
                        SaveBtn.Click();
                        Base.test.Log(LogStatus.Info, " Service Listing updated successfully");
                        return;
                    }
                    j++;
                }
                var btnNext = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/div/button[4]"));
                btnNext.Click();
            }
            var Title1 = (Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/table/tbody/tr[3]/td[2]")).Text);

            Assert.AreEqual("Test Analyst", Title1);
            Console.WriteLine(" Skills Edited Successfully");
        }
        ////Click on View Button
        //[FindsBy(How = How.XPath, Using = "//*[@id='listing-management-section']/div[2]/div[1]/table/tbody/tr[1]/td[8]/i[1]")]
        //private IWebElement ViewBtn { get; set; }
        #endregion


        #region Add Skills

        public void AddShareSkills()
        {
            //Populate the Excel Sheet
            GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkills");
            Thread.Sleep(2000);

            //Click on ShareSkills
            Thread.Sleep(5000);
            Shareskills.Click();

            //Click on Title
            Thread.Sleep(5000);
            Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title"));
            Thread.Sleep(500);

            //Click on Description
            Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description"));
            Base.test.Log(LogStatus.Info, "Description Added Sucessfully");

            //Add Category
            Thread.Sleep(4000);
            //Actions action = new Actions(GlobalDefinitions.driver);
            //action.Click(Category);
            Category.Click();
            //action.MoveToElement(Category).Build().Perform();
            Console.WriteLine("Clicked on the Category");
            Thread.Sleep(2000);
            IList <IWebElement> CategoryList = Category.FindElements(By.TagName("option"));
            int Count = CategoryList.Count;

            Thread.Sleep(500);
            for (int i = 0; i < Count; i++)
            {
                Console.WriteLine("in");

                if (CategoryList[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "Category").Trim())
                //if (CategoryList[i].Text == " Graphics & Design ".Trim())
                {
                    Thread.Sleep(1000);
                    CategoryList[i].Click();
                    Base.test.Log(LogStatus.Info, " Category Selected");
                }
            }

            //Add SubCategory
            SubCategory.Click();
            Console.WriteLine("Clicked on the SubCategory");
            Thread.Sleep(2000);
            IList <IWebElement> SubCatogeryList = SubCategory.FindElements(By.TagName("option"));

            //int count = SubCatogeryList.Count;
            Thread.Sleep(500);
            for (int i = 0; i < SubCatogeryList.Count; i++)
            {
                if (SubCatogeryList[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory").Trim())
                {
                    Thread.Sleep(1000);
                    SubCatogeryList[i].Click();
                    Base.test.Log(LogStatus.Info, " SubCategory Selected");
                }
            }

            // Add Tags
            AutoItX3 autoIt = new AutoItX3();

            Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags"));
            autoIt.Send("{Enter}");
            Base.test.Log(LogStatus.Info, " Tags Added successfully");

            // Select Service Type
            Thread.Sleep(1000);

            if (GlobalDefinitions.ExcelLib.ReadData(2, "Service Type") == " Hourly badis sevice ")
            {
                Servicetype.Click();
            }
            else
            {
                ServiceType.Click();
            }
            Base.test.Log(LogStatus.Info, "Service type Added successfully");

            //Select Location Type
            Thread.Sleep(1000);
            if (GlobalDefinitions.ExcelLib.ReadData(2, "Location Type") == "On-site")
            {
                Locationtype.Click();
            }
            else
            {
                LocationType.Click();
            }
            Base.test.Log(LogStatus.Info, "Location Type Edited successfully");

            //Monday selection
            MondayCheckBox.Click();
            MondayStartTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Start Time"));
            Thread.Sleep(1000);
            MondayEndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "End Time"));
            Thread.Sleep(1000);

            //Tuesday Selection
            TuesdayCheckBox.Click();
            TuesdayStartTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "Start Time"));
            TuesdayEndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "End Time"));

            //Wednesday Selection
            Wednesdaycheckbox.Click();
            WednesdayStartTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(4, "Start Time"));
            WednesdayEndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(4, "End Time"));

            //Selecting Skill Trade
            if (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade") == "Credit")
            {
                Thread.Sleep(1000);
                Skilltrade.Click();
            }
            else
            {
                Thread.Sleep(1000);
                SkillTrade.Click();
            }
            Base.test.Log(LogStatus.Info, " Service Listing updated successfully");

            // Enter Credit
            Thread.Sleep(1000);
            Credit.Clear();
            Credit.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit"));
            Thread.Sleep(1000);
            Base.test.Log(LogStatus.Info, " Service Listing updated successfully");

            //Upload WorkSample
            Thread.Sleep(3000);
            WorkSample.Click();
            Thread.Sleep(1000);
            AutoItX3 autoit = new AutoItX3();

            autoit.WinActivate("Open");
            autoit.Send(@"c:\users\rajesh jasti\Documents\ProfilePhoto.jpg");
            Thread.Sleep(2000);
            autoit.Send("{Enter}");
            Base.test.Log(LogStatus.Info, "Image Edited successfully");

            //Selecting Active
            Thread.Sleep(4000);
            if (GlobalDefinitions.ExcelLib.ReadData(2, "Active") == "Hidden")
            {
                Hidden.Click();
            }
            else
            {
                ActiveBtn.Click();
            }

            //Click on Save Button
            SaveBtn.Click();
        }
示例#6
0
        public void Listings()
        {
            GlobalDefinitions.Wait();
            ManageListingsLink.Click();
            //Checking the right page
            Assert.AreEqual("ListingManagement", GlobalDefinitions.driver.Title);
            Base.test = Base.extent.StartTest("On Share Manage Listing page");
            edit.Click();
            //Populate the Excel Sheet
            Global.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkill");
            Title.SendKeys(ExcelLib.ReadData(3, "Title"));
            GenericMethods.CheckLength(4, 100, ExcelLib.ReadData(3, "Title"), "Title");
            Description.SendKeys(ExcelLib.ReadData(3, "Description"));
            GenericMethods.CheckLength(4, 600, ExcelLib.ReadData(3, "Description"), "Description");
            CategoryDropDown.SendKeys(ExcelLib.ReadData(3, "Category"));
            SubCategoryDropDown.SendKeys(ExcelLib.ReadData(3, "SubCategory"));

            TxtTags.SendKeys(ExcelLib.ReadData(3, "Tags"));
            TxtTags.SendKeys(Keys.Enter);
            IWebElement ServiceTypeOptions = GlobalDefinitions.driver.FindElement(By.XPath("//div[5]//div[2]//div[1]//div[2]//div[1]//input[1]"));

            ServiceTypeOptions.Click();

            IWebElement LocationTypeOption = GlobalDefinitions.driver.FindElement(By.XPath("//div[6]//div[2]//div[1]//div[2]//div[1]//input[1]"));

            LocationTypeOption.Click();

            StartDateDropDown.SendKeys(ExcelLib.ReadData(2, "Startdate"));
            EndDateDropDown.SendKeys(ExcelLib.ReadData(2, "Enddate"));

            for (int i = 2; i < 9; i++)
            {
                for (int j = 2; j < 9; j++)
                {
                    IWebElement StartTime = GlobalDefinitions.driver.FindElement(By.XPath("//div[" + i + "]/div[2]/input"));
                    IWebElement EndTime   = GlobalDefinitions.driver.FindElement(By.XPath("//div[" + j + "]/div[3]/input"));
                    if (i == 2 && j == 2)
                    {
                        GlobalDefinitions.driver.FindElement(By.XPath("//div[contains(@class,'twelve wide column')]//div[2]//div[1]//div[1]//input[1]")).Click();
                        StartTime.SendKeys("0230PM");
                        StartTime.SendKeys(Keys.Tab);
                        EndTime.SendKeys("3052PM");
                    }
                    if (i == 3 && j == 3)
                    {
                        GlobalDefinitions.driver.FindElement(By.XPath("//div[3]//div[1]//div[1]//input[1]")).Click();
                        StartTime.SendKeys("0530PM");
                        EndTime.SendKeys("0856PM");
                    }
                }
            }

            IWebElement credit = GlobalDefinitions.driver.FindElement(By.XPath("//div[8]//div[2]//div[1]//div[2]//div[1]//input[1]"));

            if (!credit.Selected)
            {
                credit.Click();
                CreditAmount.SendKeys("9");
            }


            WorkSample.Click();

            AutoItX3 autoIt = new AutoItX3();

            autoIt.WinWait("Open", "File Upload", 1);

            autoIt.WinActivate("Open", "File Upload");

            autoIt.ControlFocus("Open", "File Upload", "[CLASS:Edit; INSTANCE:1]");

            autoIt.Send(Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..")) + "\\Test.txt");                                 //autoIt

            autoIt.Send("{ENTER}");
            autoIt.Sleep(1000);

            IWebElement ActiveOption = GlobalDefinitions.driver.FindElement(By.XPath("//form/div[10]/div[@class='twelve wide column']/div/div[@class = 'field']"));

            ActiveOption.Click();
            GlobalDefinitions.Wait();
            Save.Click();
            GlobalDefinitions.Wait();
            Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Skills edited succesfully");
            string searchInput1 = GlobalDefinitions.driver.FindElement(By.XPath("//tbody//tr[1]//td[2]")).Text;

            Assert.AreEqual(searchInput1, ExcelLib.ReadData(3, "Category"));
            string searchInput2 = GlobalDefinitions.driver.FindElement(By.XPath("//tbody//tr[1]//td[3]")).Text;

            Assert.AreEqual(searchInput2, ExcelLib.ReadData(3, "Title"));
            string searchInput3 = GlobalDefinitions.driver.FindElement(By.XPath("//tbody//tr[1]//td[5]")).Text;

            Assert.AreEqual(searchInput3, ExcelLib.ReadData(3, "ServiceType"));
        }
        public void EditSkill()
        {
            #region populate excel

            //Populate the excel data
            GlobalDefinitions.ExcelLib.PopulateInCollection(MarsResources.ExcelPath, "Managelisting");
            #endregion

            #region Enter Title
            Title.WaitForElementClickable(Global.Base.driver, 60);
            //Enter the data in Title textbox
            Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "title"));
            #endregion

            #region Enter Description
            //Enter the data in Description textbox
            Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EnterDescription"));
            #endregion

            #region Category Drop Down

            // Click on Category Dropdown
            Category.Click();
            Thread.Sleep(1000);
            // Select Category from Category Drop Down
            var selectElement = new SelectElement(Category);
            selectElement.SelectByIndex(3);
            // Click on Sub-Category Dropdown
            SubCategory.Click();
            Thread.Sleep(1000);
            //Select Sub-Category from the Drop Down
            var SelectElement1 = new SelectElement(SubCategory);
            SelectElement1.SelectByIndex(4);
            #endregion

            #region Tags
            // Eneter Tag
            Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "TagName"));
            Tags.SendKeys(Keys.Enter);
            Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "TagName"));
            Tags.SendKeys(Keys.Enter);
            #endregion

            #region Service Type Selection
            // Service Type Selection
            if (GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") == "Hourly basis service")
            {
                ServiceTypeHourly.Click();
            }
            else if (GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") == "One-off service")
            {
                ServiceTypeOnOff.Click();
            }
            #endregion

            #region Select Location Type
            // Location Type Selection

            if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectLocationType") == "On-site")
            {
                LocationTypeOnsite.Click();
            }
            else if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectLocationType") == "Online")
            {
                LocationTypeOnline.Click();
            }
            #endregion

            #region Select Available Dates from Calendar
            // Select Start Date
            //StartDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "StartDate"));
            // Select End Date
            EndDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EndDate"));
            // select available days and start time and End time
            for (int i = 2; i < 9; i++)
            {
                for (int j = 2; j < 9; j++)
                {
                    for (int k = 2; k < 9; k++)
                    {
                        IWebElement SatrtTime     = driver.FindElement(By.XPath("//div[" + i + "]/div[2]/input"));
                        IWebElement EndTime       = driver.FindElement(By.XPath("//div[" + j + "]/div[3]/input"));
                        IWebElement AvailableDays = driver.FindElement(By.XPath("//div[7]/div[2]/div/div[" + k + "]/div[1]/div/input"));
                        if (i == 2 && j == 2 && k == 2)
                        {
                            AvailableDays.Click();
                            SatrtTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "StartTime"));
                            EndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EndTime"));
                        }
                        if (i == 3 && j == 3 && k == 3)
                        {
                            AvailableDays.Click();
                            SatrtTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "StartTime"));
                            EndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "EndTime"));
                        }
                        if (i == 4 && j == 4 && k == 4)
                        {
                            AvailableDays.Click();
                            SatrtTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(4, "StartTime"));
                            EndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(4, "EndTime"));
                        }
                    }
                }
            }
            #endregion
            #region Select Skill Trade
            // Select Skill Trade
            if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectSkillTrade") == "Skill-exchange")
            {
                SkillExchange.Click();
                RequiredSkills.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "ExchangeSkill"));
                RequiredSkills.SendKeys(Keys.Enter);
                RequiredSkills.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "ExchangeSkill"));
                RequiredSkills.SendKeys(Keys.Enter);
            }
            else if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectSkillTrade") == "Credit")
            {
                CreditAmount.Click();
                CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "AmountInExchange"));
                CreditAmount.SendKeys(Keys.Enter);
            }
            #endregion

            #region Select User Status
            // Select User Status

            if (GlobalDefinitions.ExcelLib.ReadData(2, "UserStatus") == "Active")
            {
                StatusActive.Click();
            }
            else if (GlobalDefinitions.ExcelLib.ReadData(2, "UserStatus") == "Hidden")
            {
                StatusHidden.Click();
            }
            #endregion

            #region Add Work Sample
            //Click on Work sample
            WorkSample.Click();
            //AutoIT
            AutoItX3 AutoIt = new AutoItX3();
            AutoIt.WinActivate("Open");
            Thread.Sleep(3000);
            AutoIt.Send(@"A:\AdvanceTask\StandardTask\TW.docx");
            Thread.Sleep(2000);
            AutoIt.Send("{ENTER}");
            #endregion

            #region Save / Cancel Skill
            // Save or Cancel New Skill
            if (Global.GlobalDefinitions.ExcelLib.ReadData(2, "SaveOrCancel") == "Save")
            {
                Save.Click();
            }
            else if (Global.GlobalDefinitions.ExcelLib.ReadData(2, "SaveOrCancel") == "Cancel")
            {
                Cancel.Click();
            }
            #endregion

            Thread.Sleep(3000);
            #region Check whether New  skill updated sucessfully

            //String expectedValue = GlobalDefinitions.ExcelLib.ReadData(2, "title");
            // Validate view listing through Page title
            String actualTitle = driver.Title;

            // Assert.AreEqual(actualTitle, "ListingManagement");

            if (actualTitle == "ListingManagement")
            {
                Assert.IsTrue(true);
                Global.Base.test.Log(Status.Pass, "Shared Skill Successful");
                SaveScreenShotClass.SaveScreenshot(driver, "AddShareSkill");
            }
            else
            {
                Console.WriteLine("Test failed");
                SaveScreenShotClass.SaveScreenshot(driver, "FailedAddShareSkill");
                Global.Base.test.Log(Status.Fail, "Share Skill Unsuccessful");
            }
            #endregion
        }
        public void AddNewSkill()
        {
            //Populate the Excel Sheet
            Global.GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "Shareskills");
            GlobalDefinitions.wait(1);

            //Enter a Title
            Title.SendKeys(ExcelLib.ReadData(2, "Title"));
            Base.test.Log(LogStatus.Info, "Added Title successfully");

            // Enter description
            Description.SendKeys(ExcelLib.ReadData(2, "Description"));
            Base.test.Log(LogStatus.Info, "Added description successfully");

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

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

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

            //Select a subcategory from dropdown
            GlobalDefinitions.wait(2);
            action.MoveToElement(SubCategory).Build().Perform();
            GlobalDefinitions.wait(2);
            IList <IWebElement> SubCategorylist = SubCategory.FindElements(By.TagName("option"));

            for (int i = 0; i < SubCategorylist.Count; i++)
            {
                if (SubCategorylist[i].Text == ExcelLib.ReadData(2, "SubCategory"))
                {
                    SubCategorylist[i].Click();
                    Base.test.Log(LogStatus.Info, "Added Subcategory successfully");
                }
            }

            //Add Tag
            GlobalDefinitions.wait(2);
            Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tag"));
            Tags.SendKeys(Keys.Enter);
            Base.test.Log(LogStatus.Info, "Added tag successfully");

            //Select Service type
            GlobalDefinitions.wait(2);
            string ExpectedService = GlobalDefinitions.ExcelLib.ReadData(2, "Service");
            string ActualService   = ServiceType1.Text;

            if (ExpectedService == ActualService)
            {
                ServiceType1.Click();
            }
            else
            {
                ServiceType2.Click();
            }

            //Select location type
            Thread.Sleep(2000);
            GlobalDefinitions.wait(2);
            string ExpectedLocation = ExcelLib.ReadData(2, "Location");
            string ActualLocation   = Location1.Text;

            if (ExpectedLocation == ActualLocation)
            {
                Location1.Click();
            }
            else
            {
                GlobalDefinitions.wait(2);
                Location2.Click();
            }


            ////Select start Date
            GlobalDefinitions.wait(2);
            //StartDate.SendKeys(ExcelLib.ReadData(2, "StartDate"));
            //StartDate.SendKeys(Keys.Tab);
            Thread.Sleep(2000);
            string sysday = DateTime.Today.Day.ToString();

            StartDate.SendKeys(sysday);

            string sysmonth = DateTime.Today.Month.ToString();

            StartDate.SendKeys(sysmonth);

            // Select EndDate
            Thread.Sleep(2000);
            // EndDate.SendKeys(ExcelLib.ReadData(2, "EndDate"));
            EndDate.SendKeys("20/11/2020");
            GlobalDefinitions.wait(2);

            //Select Available day
            Thread.Sleep(2000);
            AvailableDay.Click();

            // Select StartTime
            Thread.Sleep(2000);
            StartTime.SendKeys(ExcelLib.ReadData(2, "StartTime"));
            Thread.Sleep(2000);

            // Select EndTime
            GlobalDefinitions.wait(1);
            EndTime.SendKeys(ExcelLib.ReadData(2, "EndTime"));
            Base.test.Log(LogStatus.Info, "Added avilable date and time successfully");
            Thread.Sleep(2000);

            //Select Skill Trade
            GlobalDefinitions.wait(2);
            string ExpectedSkillTrade = ExcelLib.ReadData(2, "Skill Trade");
            string ActualSkillTrade   = SkillExchange.Text;

            if (ExpectedSkillTrade == ActualSkillTrade)
            {
                SkillExchange.Click();
                //Enter skill for exchange
                SkillExchangeTag.SendKeys(ExcelLib.ReadData(2, "Skillexchange"));
            }
            else
            {
                Credit.Click();
                //Enter rate
                CreditRate.Clear();
                CreditRate.SendKeys(ExcelLib.ReadData(2, "Rate"));
            }

            //Upload WorkSample Images
            string MyWork = ExcelLib.ReadData(2, "UploadImage");

            WorkSample.Click();
            AutoItX3 autoit = new AutoItX3();

            autoit.WinActivate("Open");
            autoit.Send(MyWork);
            GlobalDefinitions.wait(1);
            autoit.Send("{Enter}");
            Base.test.Log(LogStatus.Info, "Uploaded image successfully");
            Thread.Sleep(2000);

            //Select active/ Hidden button
            GlobalDefinitions.wait(1);
            GlobalDefinitions.wait(2);
            string ExpectedAction = ExcelLib.ReadData(2, "Location");
            string ActualAction   = ActiveBtn.Text;

            if (ExpectedAction == ActualAction)
            {
                ActiveBtn.Click();
            }
            else
            {
                GlobalDefinitions.wait(2);
                HiddenBtn.Click();
            }

            //Check if save button enabled
            GlobalDefinitions.wait(2);
            if (SaveBtn.Enabled)
            {
                // Click on Save button
                GlobalDefinitions.wait(2);
                SaveBtn.Click();
                Thread.Sleep(10000);
                try
                {
                    //Check for Skill share success message
                    Thread.Sleep(2000);
                    GlobalDefinitions.wait(2);
                    String ExpectedMessage = "Service Listing Added Successfully";
                    Thread.Sleep(10000);
                    String ActualMessage = driver.FindElement(By.CssSelector("div.ns-box-inner")).Text;
                    Assert.AreEqual(ExpectedMessage, ActualMessage);
                    Base.test.Log(LogStatus.Info, "Skill saved Successfully");
                }
                catch (Exception)
                {
                    Base.test.Log(LogStatus.Info, "Skill saved Successfully");
                }
            }
            else
            {
                SaveScreenShotClass.SaveScreenshot(driver, "Save button not enabled");
                Base.test.Log(LogStatus.Info, "Save button not enabled");
            }


            //Search for the Shared skill in Manage Listing page

            GlobalDefinitions.wait(2);

            //Click on manage listing
            driver.FindElement(By.LinkText("Manage Listings")).Click();
            Thread.Sleep(1000);

            //Check if navigated to service listing page
            try
            {
                string Expected = "Manage Listings";
                string Actual   = driver.FindElement(By.XPath("//div[@id='listing-management-section']/div[2]/h2")).Text;
                Assert.AreEqual(Expected, Actual);

                Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Navigated to manage listing page");
                string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Navigated to manage listing page");
                Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath));
            }
            catch (Exception)
            {
                Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Could not navigate to Manage listing page");
                string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Could not navigate to Manage listing page");
                Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath));
            }

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

            string BeforeXPath = "//div[@id='listing-management-section']/div[2]/div/table/tbody/tr[";
            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.Info, "Skill present in Manage Listing ");
                    string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Skill present in Manage Listing");
                    Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Info, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath));
                    break;
                }
                else
                {
                    Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Skill not present in Manage Listing ");
                    string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Skill not present in Manage Listing");
                    Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath));
                }
            }
        }
        public void EnterShareSkill()
        {
            GlobalDefinitions.Wait();
            ShareSkillButton.Click();
            //Checking the right page
            Assert.AreEqual("ServiceListing", GlobalDefinitions.driver.Title);
            Base.test = Base.extent.StartTest("On Share Skill page");
            //Populate the Excel Sheet
            Global.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkill");
            //Enter TITLE
            Title.SendKeys(ExcelLib.ReadData(2, "Title"));
            //Check Length of Title
            GenericMethods.CheckLength(4, 100, ExcelLib.ReadData(2, "Title"), "Title");
            //Enter Description
            Description.SendKeys(ExcelLib.ReadData(2, "Description"));
            GenericMethods.CheckLength(4, 600, ExcelLib.ReadData(2, "Description"), "Description");
            //Select Category form dropdown
            CategoryDropDown.SendKeys(ExcelLib.ReadData(2, "Category"));
            SubCategoryDropDown.SendKeys(ExcelLib.ReadData(2, "SubCategory"));
            //Enter tag
            TxtTags.SendKeys(ExcelLib.ReadData(2, "Tags"));
            TxtTags.SendKeys(Keys.Enter);
            //Select service Type
            IWebElement ServiceTypeOptions = GlobalDefinitions.driver.FindElement(By.XPath("//form/div[5]/div[@class='twelve wide column']/div/div[@class='field']"));

            ServiceTypeOptions.Click();
            //Select Location Type
            IWebElement LocationTypeOption = GlobalDefinitions.driver.FindElement(By.XPath("//div[6]//div[2]//div[1]//div[1]//div[1]//input[1]"));

            LocationTypeOption.Click();
            //Enter start Date and End date
            StartDateDropDown.SendKeys(ExcelLib.ReadData(2, "Startdate"));
            EndDateDropDown.SendKeys(ExcelLib.ReadData(2, "Enddate"));
            // Loop for no. of days available,Start time and End time
            for (int i = 2; i < 9; i++)
            {
                for (int j = 2; j < 9; j++)
                {
                    IWebElement StartTime = GlobalDefinitions.driver.FindElement(By.XPath("//div[" + i + "]/div[2]/input"));
                    IWebElement EndTime   = GlobalDefinitions.driver.FindElement(By.XPath("//div[" + j + "]/div[3]/input"));
                    if (i == 2 && j == 2)
                    {
                        GlobalDefinitions.driver.FindElement(By.XPath("//div[contains(@class,'twelve wide column')]//div[2]//div[1]//div[1]//input[1]")).Click();
                        StartTime.SendKeys("0230PM");
                        StartTime.SendKeys(Keys.Tab);
                        EndTime.SendKeys("3052PM");
                    }
                    if (i == 3 && j == 3)
                    {
                        GlobalDefinitions.driver.FindElement(By.XPath("//div[3]//div[1]//div[1]//input[1]")).Click();
                        StartTime.SendKeys("0530PM");
                        EndTime.SendKeys("0856PM");
                    }
                }
            }
            // Select Skill Trade
            IWebElement credit = GlobalDefinitions.driver.FindElement(By.XPath("//div[8]//div[2]//div[1]//div[2]//div[1]//input[1]"));

            //Checking if the radio is selected or not
            if (!SkillTradeOption.Selected)
            {
                SkillTradeOption.Click();
            }
            Boolean status = GlobalDefinitions.driver.FindElement(By.XPath("//input[@type='radio']")).Selected;

            //To Check Radiobutton is selected or not
            if (status)
            {
                Console.WriteLine("RadioButton is checked");
            }
            else
            {
                Console.WriteLine("RadioButton is unchecked");
            }
            //Enter SkillExchange
            SkillExchange.SendKeys(ExcelLib.ReadData(2, "Skill-Exchange"));
            SkillExchange.SendKeys(Keys.Enter);
            //Upload File Using Auto IT
            WorkSample.Click();

            AutoItX3 autoIt = new AutoItX3();

            autoIt.WinWait("Open", "File Upload", 1);

            autoIt.WinActivate("Open", "File Upload");


            autoIt.ControlFocus("Open", "File Upload", "[CLASS:Edit; INSTANCE:1]");

            autoIt.Send(Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..")) + "\\Test.txt");
            autoIt.Sleep(1000);
            autoIt.Send("{ENTER}");
            //	autoIt.Sleep(1000);
            //Select Active Type
            IWebElement ActiveOption = GlobalDefinitions.driver.FindElement(By.XPath("//form/div[10]/div[@class='twelve wide column']/div/div[@class = 'field']"));

            ActiveOption.Click();
            GlobalDefinitions.Wait();
            Save.Click();
            GlobalDefinitions.Wait();

            Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Skills Added Successfully");
            //Assert.AreEqual("ServiceListing", GlobalDefinitions.driver.Title);

            //Assert on category / title / Service Type after adding the skill and displayed on Manage Listing Page
            string searchInput1 = GlobalDefinitions.driver.FindElement(By.XPath("//td[contains(text(),'Programming & Tech')]")).Text;

            Console.WriteLine(searchInput1);
            Assert.AreEqual(searchInput1, ExcelLib.ReadData(2, "Category"));

            string searchInput2 = GlobalDefinitions.driver.FindElement(By.XPath("//table[@class='ui striped table']//tbody//tr[1]//td[3]")).Text;

            Console.WriteLine(searchInput2);
            Assert.AreEqual(searchInput2, ExcelLib.ReadData(2, "Title").TrimEnd());

            //string searchInput3 = GlobalDefinitions.driver.FindElement(By.XPath("//table[@class='ui striped table']//tbody//tr[1]//td[5]")).Text;
            //Assert.AreEqual(searchInput3, ExcelLib.ReadData(2, "ServiceType"));
        }
示例#10
0
        internal void AddService()
        {
            //Populate the Excel Sheet
            GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkill");
            GlobalDefinitions.wait(10);

            //Check if user is able to click on ShareSkill button
            ShareSkillbtn.Click();
            GlobalDefinitions.wait(10);
            Boolean isPresent = GlobalDefinitions.driver.FindElements(By.XPath("//input[@name='title']")).Count > 0;

            if (isPresent == true)
            {
                Base.test.Log(LogStatus.Pass, "Share Skill button is clicked Successfully");
            }
            else
            {
                Base.test.Log(LogStatus.Fail, "Share Skill button Click is UnSuccessful");
            }

            //Check if user is able to enter valid data as Title
            Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title"));
            //checking for invalid data
            Boolean isError = GlobalDefinitions.driver.FindElements(By.XPath("//div[@class='ui basic red prompt label transition visible']")).Count > 0;

            if (isError == true)
            {
                if (Invalid.Text == GlobalDefinitions.ExcelLib.ReadData(2, "Title Error Message"))
                {
                    Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Error displayed as expected: First character must be an alphabet character or a number");
                }
            }
            else
            {
                //Check if user is able to Enter Title
                Boolean isTitleFetched = GlobalDefinitions.driver.FindElements(By.XPath("//input[@value='Software Tester']")).Count > 0;
                if (isTitleFetched == true)
                {
                    Base.test.Log(LogStatus.Pass, "Title is Fetched from The Excel Successfully");
                }
                else
                {
                    Base.test.Log(LogStatus.Fail, "Title is not fetched correctly");
                }
            }


            //Check if user is able to enter valid data as description
            Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description"));
            //checking for invalid data
            if (isError == true)
            {
                if (Invalid.Text == GlobalDefinitions.ExcelLib.ReadData(2, "Title Error Message"))
                {
                    Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Error displayed as expected: Special characters are not allowed");
                }
            }
            //code for valid data
            else
            {
                if (Description.Text == GlobalDefinitions.ExcelLib.ReadData(2, "Description"))
                {
                    Base.test.Log(LogStatus.Pass, "Description is Fetched from The Excel Successfully");
                }
                else
                {
                    Base.test.Log(LogStatus.Fail, "Description is not fetched correctly");
                }
            }

            //Check if user is able to select Category
            CategoryId.Click();
            IList <IWebElement> Category = CategoryId.FindElements(By.TagName("option"));
            int categorycount            = Category.Count;

            for (int i = 0; i < categorycount; i++)
            {
                if (Category[i].Text == GlobalDefinitions.ExcelLib.ReadData(2, "CategoryId"))
                {
                    Category[i].Click();
                    Base.test.Log(LogStatus.Pass, "Selected Category");
                    break;
                }
                else
                {
                    Base.test.Log(LogStatus.Info, "Cant find Category");
                }
            }

            //Check if user is able to choose Subcategory
            SubcategoryId.Click();
            IList <IWebElement> SubCategory = SubcategoryId.FindElements(By.TagName("option"));
            int subcategorycount            = SubCategory.Count;

            for (int j = 0; j < subcategorycount; j++)
            {
                if (SubCategory[j].Text == GlobalDefinitions.ExcelLib.ReadData(2, "SubcategoryId"))
                {
                    SubCategory[j].Click();
                    Base.test.Log(LogStatus.Pass, "Selected Subcategory");
                    break;
                }
                else
                {
                    Base.test.Log(LogStatus.Info, "Cant find Subcategory");
                }
            }


            //Check if user is able to Enter valid tags
            Boolean isTagPresent = GlobalDefinitions.driver.FindElements(By.XPath("//span[contains(.,'test')]")).Count > 0;

            if (isTagPresent == true)
            {
                Base.test.Log(LogStatus.Info, "Tag already exists");
            }
            else
            {
                Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags"));
                Tags.SendKeys(Keys.Enter);
                Tags.SendKeys(Keys.Tab);
                Base.test.Log(LogStatus.Pass, "Tag added successfully");
            }

            //Check if user is able to select Service Type
            switch (GlobalDefinitions.ExcelLib.ReadData(2, "Service Type"))
            {
            case "Hourlybasis":
                HourlybasisServiceButton.Click();
                Base.test.Log(LogStatus.Pass, "Hourly basis service is selected");
                break;

            case "One-off":
                OneoffServiceButton.Click();
                Base.test.Log(LogStatus.Pass, "One-off service is selected");
                break;
            }

            //Check if user is able to select Location Type
            switch (GlobalDefinitions.ExcelLib.ReadData(2, "Location Type"))
            {
            case "On-site":
                OnsiteButton.Click();
                Base.test.Log(LogStatus.Pass, "Onsite location type is selected");
                break;

            case "Online":
                OnlineButton.Click();
                Base.test.Log(LogStatus.Pass, "Online location type is selected");
                break;
            }

            //Check if user is able to enter valid Date
            StartDate.Click();
            GlobalDefinitions.wait(10);
            StartDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "StartDate"));
            //checking for invalid start date
            if (isError == true)
            {
                if (Invalid.Text == GlobalDefinitions.ExcelLib.ReadData(2, "Title Error Message"))
                {
                    Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Error displayed as expected: Start Date cannot be set to a day in the past");
                }
            }
            EndDate.Click();
            GlobalDefinitions.wait(10);
            EndDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EndDate"));
            Day.Click();
            GlobalDefinitions.wait(10);

            //Check if user is able to select Time
            StartTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "StartTime"));
            EndTime.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EndTime"));
            Base.test.Log(LogStatus.Pass, "Availability is selected");

            //Check if user is able to slect Skill-Trade
            switch (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade"))
            {
            case "Skill-exchange":
                SkillExchangebutton.Click();
                Boolean isSkillTagPresent = GlobalDefinitions.driver.FindElements(By.XPath("//span[contains(.,'cooking')]")).Count > 0;
                if (isTagPresent == true)
                {
                    Base.test.Log(LogStatus.Info, "Tag already exists");
                }
                else
                {
                    SkillTag.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skills"));
                    SkillTag.SendKeys(Keys.Enter);
                    SkillTag.SendKeys(Keys.Tab);
                    Base.test.Log(LogStatus.Pass, "SkillTag is fetched successfully");
                }
                break;

            case "Credit":
                Creditbutton.Click();
                Base.test.Log(LogStatus.Info, "Credit is selected");
                Credit.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit"));
                Boolean isCreditFetched = GlobalDefinitions.driver.FindElements(By.XPath("//input[@value='10']")).Count > 0;
                if (isCreditFetched == true)
                {
                    Base.test.Log(LogStatus.Pass, "Credit is Fetched from The Excel Successfully");
                }
                else
                {
                    Base.test.Log(LogStatus.Fail, "Credit is not fetched correctly");
                }
                break;
            }

            //Check if user is able to Upload worksample using AutoIt tool
            WorkSample.Click();
            Thread.Sleep(1000);
            AutoItX.WinActivate("Open");
            AutoItX.Send(GlobalDefinitions.ExcelLib.ReadData(2, "Upload File Path"));
            Thread.Sleep(1000);
            AutoItX.Send("{Enter}");
            Boolean isWorksampleUploaded = GlobalDefinitions.driver.FindElements(By.XPath("//a[text()='dd.txt']")).Count > 0;

            if (isWorksampleUploaded == true)
            {
                Base.test.Log(LogStatus.Pass, "Uploaded file successfully");
            }
            else
            {
                Base.test.Log(LogStatus.Fail, "File Updation Unsuccessful");
            }

            //Check if user is able to choose state
            switch (GlobalDefinitions.ExcelLib.ReadData(2, "State"))
            {
            case "Active":
                GlobalDefinitions.wait(60);
                Activebutton.Click();
                Base.test.Log(LogStatus.Pass, "Active state is selected");
                break;

            case "Hidden":
                Hiddenbutton.Click();
                Base.test.Log(LogStatus.Pass, "Hidden state is selected");
                break;
            }

            //Check if user is able to click Save button
            Savebtn.Click();
            Base.test.Log(LogStatus.Pass, "Save button is clicked");
        }