public void QATest() { CSVHandler CSV = new CSVHandler(); Excel.Worksheet Sheet = CSV.OpenCSV(@"C:\Users\Milijana\Desktop\ddt6.csv"); int rows = Sheet.UsedRange.Rows.Count; int columns = Sheet.UsedRange.Columns.Count; string name, description, expected, FirstName, LastName, Email, UN, P, CP; bool IsExpected = true; for (int i = 2; i <= rows; i++) { TestContext.Write("Name of Test Case: {0},Description: {1},Expected: {2} ", Sheet.Cells[i, 1].Value, Sheet.Cells[i, 2].Value, Sheet.Cells[i, 3].Value); FileManagment.Scrivi("Name of Test Case: " + Sheet.Cells[i, 1].Value.ToString() + " Description: " + Sheet.Cells[i, 2].Value.ToString() + " Expected: " + Sheet.Cells[i, 3].Value); name = Sheet.Cells[i, 1].Value; description = Sheet.Cells[i, 2].Value; expected = Sheet.Cells[i, 3].Value; FirstName = Sheet.Cells[i, 4].Value; LastName = Sheet.Cells[i, 5].Value; Email = Sheet.Cells[i, 6].Value; UN = Sheet.Cells[i, 7].Value; P = Sheet.Cells[i, 8].Value; CP = Sheet.Cells[i, 9].Value; ShopHomePage pocetna = new ShopHomePage(driver); pocetna.GoToPage(); Register R; R = pocetna.ClicReg(); pocetna = R.ClickButtonRegister(FirstName, LastName, Email, UN, P, CP); if (pocetna.Uspeh != null) { if (expected == "pass") { TestContext.WriteLine(" Successful Test!!! "); FileManagment.Scrivere(" Successful Test!!! "); } else { TestContext.WriteLine(" The test is failed!!! "); FileManagment.Scrivere(" The test is failed!!! "); IsExpected = false; } } else { if (expected == "fail") { TestContext.WriteLine(" Successful Test!!! "); FileManagment.Scrivere(" Successful Test!!! "); } else { TestContext.WriteLine(" The test is failed!!! "); FileManagment.Scrivere(" Successful Test!!! "); IsExpected = false; } } TestContext.WriteLine("----------------------------------------------------------------------------------------------------------------------------------------------"); FileManagment.Scrivere("---------------------------------------------------------------------------------------------------------------------------------------------"); } if (IsExpected == true) { Assert.Pass("Great job!!!"); } else { Assert.Fail("Some test has an unexpected result!!!"); } CSV.Close(); }
private void Log(string Message) { FileManagment.Scrivi(Message); TestContext.Write(Message); }