public void CromMethod() { string ActualResult; string ExpectedResult = "Guru99 Bank Home Page"; IWebDriver driver = new ChromeDriver(); driver.Navigate().GoToUrl("http://demo.guru99.com/V4/"); driver.Manage().Window.Maximize(); driver.FindElement(By.Name("uid")).SendKeys("uid"); driver.FindElement(By.Name("password")).SendKeys("password"); driver.FindElement(By.Name("btnLogin")).Click(); ActualResult = driver.Title; if (ActualResult.Contains(ExpectedResult)) { SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Server=[server_name];Database=[database_name];Trusted_Connection=true"; conn.Open(); SqlCommand insertCommand = new SqlCommand("INSERT INTO Status (Status, Scenario, TestDescription) VALUES (@1, @3, @2)", conn); insertCommand.Parameters.Add(new SqlParameter("1", "Pass")); insertCommand.Parameters.Add(new SqlParameter("2", DateTime.Now)); insertCommand.Parameters.Add(new SqlParameter("3", "QA1")); Console.WriteLine("Commands executed! Total rows affected are " + insertCommand.ExecuteNonQuery()); Console.ReadLine(); Assert.IsTrue(true, "Test Case passed"); } else { SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Server=[server_name];Database=[database_name];Trusted_Connection=true"; conn.Open(); SqlCommand insertCommand = new SqlCommand("INSERT INTO Status (Status, Scenario, TestDescription) VALUES (@1, @3, @2)", conn); insertCommand.Parameters.Add(new SqlParameter("1", "Fail")); insertCommand.Parameters.Add(new SqlParameter("2", DateTime.Now)); insertCommand.Parameters.Add(new SqlParameter("3", "QA1")); } driver.Close(); driver.Quit(); }
public void ChromeMethod() { string ActualResult; string ExecptedResult = "Bing"; IWebDriver driver = new ChromeDriver(); driver.Navigate().GoToUrl("https://www.google.com/"); driver.Manage().Window.Maximize(); ActualResult = driver.Title; if (ActualResult.Contains(ExecptedResult)) { Console.WriteLine("Test Passed"); Assert.IsTrue(true, "Test Passed"); } else { Console.WriteLine("Test Failed"); } driver.Close(); driver.Quit(); }
public void CheckTitle() { string ActualResult; string ExpectedResult = "Google"; IWebDriver driver = new FirefoxDriver(); driver.Navigate().GoToUrl("https://www.google.com/"); driver.Manage().Window.Maximize(); ActualResult = driver.Title; if (ActualResult.Contains(ExpectedResult)) { Assert.IsTrue(true, "Test Case Passed"); } else { Assert.IsFalse(false, "Test case failed"); } driver.Close(); driver.Quit(); }
public void ChromeMethod1() { string ActualResult; string ExpectedResult = "Google"; IWebDriver driver = new ChromeDriver(); driver.Navigate().GoToUrl("https://www.google.com/"); driver.Manage().Window.Maximize(); ActualResult = driver.Title; if (ActualResult.Contains(ExpectedResult)) { Console.WriteLine("Test Case Passed"); } else { Console.WriteLine("Test Case Failed"); } Thread.Sleep(4000); driver.Close(); driver.Quit(); }
public void FireFoxMethod() { string ActualResult; string ExpectedResult = "Google"; IWebDriver driver = new FirefoxDriver(); driver.Navigate().GoToUrl("https://www.google.com/"); driver.Manage().Window.Maximize(); ActualResult = driver.Title; if (ActualResult.Contains(ExpectedResult)) { Console.WriteLine("Test case passed"); Assert.IsTrue(true, "Test case passed"); } else { Console.WriteLine("Test case failed"); } driver.Close(); driver.Quit(); }