public void Inititalize() { //advisasble to read this documentation before proceeding http://extentreports.relevantcodes.com/net/ switch (Browser) { case 1: GlobalDefinitions.driver = new FirefoxDriver(); break; case 2: GlobalDefinitions.driver = new ChromeDriver(); GlobalDefinitions.driver.Manage().Window.Maximize(); break; } //nevigate to home page GlobalDefinitions.driver.Navigate().GoToUrl("http://192.168.99.100:5000/Home"); #region Initialise Reports extent = new ExtentReports(ReportPath, false, DisplayOrder.NewestFirst); extent.LoadConfig(ReportXMLPath); //GlobalDefinitions.driver.Quit(); #endregion if (MarsResource.IsLogin == "true") { //Create Extent Report //test = extent.StartTest("Login Test"); SignIn loginobj = new SignIn(); loginobj.LoginSteps(); GlobalDefinitions.wait(30); //Thread.Sleep(10000); //try //{ // string ExpectedUserName = "******"; // //driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); // string ActualUserName = loginobj.ValidUserName.Text; // Assert.AreEqual(ExpectedUserName, ActualUserName); // Console.WriteLine($"User name is correct as Expected {ActualUserName}"); // //Base.test.Log(LogStatus.Pass, "Login Successful"); //} //catch (NoSuchElementException) //{ // Console.Write("User Name not found"); // //test.Log(LogStatus.Fail, "Login Unsuccessful"); //} } else { SignUp obj = new SignUp(); obj.register(); } }
public static void SelectDayTime(IWebDriver driver, String Days, IWebElement Sunday, IWebElement Monday, IWebElement Tuesday, IWebElement Wednesday, IWebElement Thursday, IWebElement Friday, IWebElement Saturday) { switch (Days) { case "Sun": { Sunday.Click(); GlobalDefinitions.wait(1500); driver.FindElement(By.XPath("//input[@name='StartTime'][@index='0']")).Clear(); driver.FindElement(By.XPath("//input[@name='StartTime'][@index='0']")).SendKeys((GlobalDefinitions.ExcelLib.ReadData(2, "Starttime"))); GlobalDefinitions.wait(1500); driver.FindElement(By.XPath("//input[@name='EndTime'][@index='0']")).Clear(); driver.FindElement(By.XPath("//input[@name='EndTime'][@index='0']")).SendKeys((GlobalDefinitions.ExcelLib.ReadData(2, "Endtime"))); break; } case "Mon": { Monday.Click(); GlobalDefinitions.wait(1500); driver.FindElement(By.XPath("//input[@name='StartTime'][@index='1']")).Click(); driver.FindElement(By.XPath("//input[@name='StartTime'][@index='1']")).SendKeys(((GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")))); GlobalDefinitions.wait(1500); driver.FindElement(By.XPath("//input[@name='EndTime'][@index='1']")).Click(); driver.FindElement(By.XPath("//input[@name='EndTime'][@index='1']")).SendKeys((GlobalDefinitions.ExcelLib.ReadData(2, "Endtime"))); break; } case "Tue": { Tuesday.Click(); driver.FindElement(By.XPath("//input[@name='StartTime'][@index='2']")).SendKeys((GlobalDefinitions.ExcelLib.ReadData(2, "Starttime"))); driver.FindElement(By.XPath("//input[@name='EndTime'][@index='2']")).SendKeys((GlobalDefinitions.ExcelLib.ReadData(2, "Endtime"))); break; } case "Wed": { Wednesday.Click(); driver.FindElement(By.XPath("//input[@name='StartTime'][@index='3']")).SendKeys((GlobalDefinitions.ExcelLib.ReadData(2, "Starttime"))); driver.FindElement(By.XPath("//input[@name='EndTime'][@index='3']")).SendKeys((GlobalDefinitions.ExcelLib.ReadData(2, "Endtime"))); break; } case "Thu": { Thursday.Click(); driver.FindElement(By.XPath("//input[@name='StartTime'][@index='4']")).SendKeys((GlobalDefinitions.ExcelLib.ReadData(2, "Starttime"))); driver.FindElement(By.XPath("//input[@name='EndTime'][@index='4']")).SendKeys((GlobalDefinitions.ExcelLib.ReadData(2, "Endtime"))); break; } case "Fri": { Friday.Click(); driver.FindElement(By.XPath("//input[@name='StartTime'][@index='5']")).SendKeys((GlobalDefinitions.ExcelLib.ReadData(2, "Starttime"))); driver.FindElement(By.XPath("//input[@name='EndTime'][@index='5']")).SendKeys((GlobalDefinitions.ExcelLib.ReadData(2, "Endtime"))); break; } case "Sat": { Saturday.Click(); driver.FindElement(By.XPath("//input[@name='StartTime'][@index='6']")).SendKeys((GlobalDefinitions.ExcelLib.ReadData(2, "Starttime"))); driver.FindElement(By.XPath("//input[@name='EndTime'][@index='6']")).SendKeys((GlobalDefinitions.ExcelLib.ReadData(2, "Endtime"))); break; } } }