public void TC_CheckStartDate() { try { GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkill"); test = extent.StartTest("Create New Share Skill Record"); // create an object for serviceLIsting page ServiceListing skillObj = new ServiceListing(); //click on the share skill button skillObj.ShareSkillBtnClick(); //enter all the details from the excel string title = GlobalDefinitions.ExcelLib.ReadData(4, "Title"); string desc = GlobalDefinitions.ExcelLib.ReadData(4, "Description"); skillObj.inputTitleDescription(title, desc); //enter category and sub category details skillObj.SelectCategSubcateg(GlobalDefinitions.ExcelLib.ReadData(4, "Category"), GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory")); // enter tags value skillObj.InputTags(GlobalDefinitions.ExcelLib.ReadData(4, "Tags")); //enter service type and location type skillObj.ServiceAndLocationTypeSelect(GlobalDefinitions.ExcelLib.ReadData(4, "ServiceType"), GlobalDefinitions.ExcelLib.ReadData(4, "LocationType")); //enter yesterday as start date in Available days DateTime date = DateTime.Today.AddDays(-1); skillObj.StartDateSelect(date.ToString("dd-MM-yyyy")); //enter skill trade details skillObj.inputCreditTradeDetails(GlobalDefinitions.ExcelLib.ReadData(4, "credit")); //enter active status skillObj.ActiveBtnClick(); //click on save button skillObj.SaveBtnClick(); Thread.Sleep(2000); if (skillObj.ShareSkillPageTitle().Equals("ServiceListing")) { if (skillObj.IsErrorDateMsg().Equals("Start Date cannot be set to a day in the past")) { Base.test.Log(LogStatus.Pass, "Test Passed- Past date not accepting as start date"); Assert.True(true); } else { Base.test.Log(LogStatus.Fail, "Test Failed - should return proper error message for past date"); Assert.Fail(); } } else { Base.test.Log(LogStatus.Fail, "Test Failed - Should not save the record with past date as start date"); Assert.Fail(); } } catch (Exception e) { Base.test.Log(LogStatus.Fail, e); Assert.Fail(); } }