public static void TestComplexStructures() { SeleniumLog log = SeleniumLog.Instance(); string str = "Hello World"; Hashtable ht = new Hashtable(); ht.Add("k1", "v1"); ht.Add("k2", "v2"); TestClass tc = new TestClass(); datastruct1 DS = new datastruct1(); datastruct2 DS2 = new datastruct2(); //tc.Method1(100, 250, DS); //Console.ReadLine(); //log.WriteLine("Exploring DS"); ///log.Indent(); //log.Explore(DS2, comment: "Exporing DS structure"); //log.Unindent(); //log.WriteLine("Exploring DS2"); //log.Indent(); // It is the combination of these two calls that causes the indentation error log.Explore(ht, comment: "Exporing ht structure"); log.Explore(DS, comment: "Exploring DS structure"); log.Explore(DS2, comment: "Exploring DS2 structure"); //log.Explore(DS, comment: "Exploring DS structure"); //log.Unindent(); //log.Explore(DS2, comment: "Exploring DS2 structure again"); log.Explore(str, comment: "Exploring string"); }
public void test() { try { SeleniumLog log = SeleniumLog.Instance(); //ApiField.Click(); //log.WriteLine("Field default text [" + ApiField.GetAttribute("placeholder") + "]"); //ApiField.SendKeys("test"); //SearchField.SendKeys("Toyota"); //SearchButton.Click(); //log.WriteLine("Ad count [" + AdsList.Count + "]"); //log.WriteLine("Sleep 3 seconds"); //Thread.Sleep(3000); //log.WriteLine("Finished sleeping"); //ScrollIntoView(ResultsCount); log.WriteLine("end test"); } catch (Exception e) { SeleniumLog log = SeleniumLog.Instance(); log.Error().WriteLine("Exception: " + e.Message); } }
public TestCase() { ChromeDriver driver0 = new ChromeDriver(); driver = new SeleniumLogEventListener(driver0); Home = new HomePage(driver); Contact = new ContactUsPage(driver); SeleniumLog log = SeleniumLog.Instance(driver); //Only need to pass in driver once as it is a Singleton object }
public void TestCase1() { SeleniumLog log = SeleniumLog.Instance(); log.Path("Test Case 1"); SelectFlight( FROM: "Boston", TO: "Rome", FLIGHTNUM: 622 ); }
public void TestCase2() { SeleniumLog log = SeleniumLog.Instance(); log.Path("Test Case 2"); SelectFlight( FROM: "Paris", TO: "Berlin", FLIGHTNUM: 15 ); }
public void TestCase3() { SeleniumLog log = SeleniumLog.Instance(); log.Path("Test Case 3"); SelectFlight( FROM: "Paris", TO: "London", FLIGHTNUM: 711 ); }
static void Main(string[] args) { SeleniumLog log = SeleniumLog.Instance(null); log.WriteLine("Launch Chrome"); ChromeOptions options = new ChromeOptions(); options.AddArgument("--start-maximized"); int ExpectedCount = -1; int ActualCount = -1; IWebDriver driver = new ChromeDriver(options); GumtreeWebsite.MainPage GumtreeMain = new GumtreeWebsite.MainPage(driver); log.WriteLine("Goto GUMTREE URL"); driver.Navigate().GoToUrl("http://gumtree.com.au"); log.WriteLine("Run Test"); MainPage MainPage = new MainPage(driver); SearchResultsPage SearchResultsPage = new SearchResultsPage(driver); CarDetailsPage CarDetailsPage = new CarDetailsPage(driver); MainPage.Search("Toyota"); log.WriteLine("Currently on Page 1 ....."); ExpectedCount = SearchResultsPage.GetDisplayedResultsCountPerPage(); log.WriteLine("Displayed results per page [" + ExpectedCount + "]"); ActualCount = SearchResultsPage.CountSearchResults(); log.WriteLine("Actual number of results [" + ActualCount + "]"); log.WriteLine("Goto Page 2"); SearchResultsPage.GotoPage(2); log.WriteLine("Goto Page 3"); SearchResultsPage.GotoPage(3); log.WriteLine("Goto Page 4"); SearchResultsPage.GotoPage(4); log.WriteLine("\n\n********** While on Page 4, click on random advert *******************"); SearchResultsPage.ClickOnRandomSearchResult(); CarDetailsPage.ClickImageButton(); CarDetailsPage.CycleThroughAllImages(); //Close Browser driver.Close(); driver.Quit(); }
static void Main(string[] args) { FirefoxDriver driver0 = new FirefoxDriver(); SeleniumLogEventListener driver = new SeleniumLogEventListener(driver0); SeleniumLog log = SeleniumLog.Instance(driver); TestClass tobj = new TestClass(); log.WriteLine("Main"); Foo(); tobj.Message("hi there"); }
public DUMMYSITE_TEST_CASES() { IWebDriver driver0 = new ChromeDriver(@"C:\Selenium Drivers"); //IWebDriver driver0 = new InternetExplorerDriver(@"C:\Selenium Drivers"); driver1 = new SeleniumLogEventListener(driver0); //Bind Selenium Event Listener to driver1 SeleniumLog log = SeleniumLog.Instance(driver0); //Initialise SeleniumLog with driver1 instance (containing an Event Listener already) pom = new PAGE_OBJECT_MODEL(driver1); driver1.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(60)); driver1.Navigate().GoToUrl("http://www.dummysite.net"); }
public BasePage(IWebDriver driver) { try { this.driver = driver; this.log = SeleniumLog.Instance(); ResetDefaultTimeout(); } catch (Exception e) { } }
/// <summary> /// Goto seleniumlog.com URL /// </summary> public void Goto() { SeleniumLog log = SeleniumLog.Instance(); log.SaveIndent("Function-goto"); log.Blue().WriteLine("Function: Goto()"); log.Indent(); driver.Navigate().GoToUrl("http://seleniumlog.com/"); log.RestoreIndent("Function-goto"); //Ensures unindent back to correct level }
public void Message(string msg) { try { SeleniumLog log = SeleniumLog.Instance(); log.WriteLine(string.Format("TestClass :: Message :: {0}", msg)); } catch (Exception e) { SeleniumLog log = SeleniumLog.Instance(); log.Error().WriteLine(string.Format("TestClass :: Exception :: {0}", e.Message)); } }
public void Run() { SeleniumLog log = SeleniumLog.Instance(); log.Path("TestCase 1: Site navigation"); log.WriteLine("Step 1: Goto Seleniumlog.com website"); log.Indent(); Home.Goto(); log.Unindent(); //log.WriteLine("Step 2: Goto Buy Now page"); //Home.BuyNow.Click(); log.WriteLine("Step 3: Goto Contact Us page"); Home.ContactUs.Click(); Thread.Sleep(2000); log.WriteLine("Step 4: Enter First Name"); Contact.FirstName.SendKeys("James"); log.WriteLine("Step 5: Enter Last Name"); Contact.LastName.SendKeys("Smith"); log.WriteLine("Step 6: Enter Email address"); Contact.Email.SendKeys("james.smith.seleniumlog.com"); log.WriteLine("Step 7: Enter Comments"); Contact.Comment.SendKeys("Hello World!"); log.WriteLine("Step 8: Click on Submit button"); Contact.Submit.Click(); log.WriteLine("Step 9: Verify not submitted"); log.Indent(); Contact.VerifyNotSubmitted(); log.Unindent(); log.WriteLine("Step 10: Re-Enter Email address"); Contact.Email.SendKeys("*****@*****.**"); log.WriteLine("Step 11: Click on Submit button"); Contact.Submit.Click(); log.WriteLine("Step 12: Verify submitted successfully"); log.Indent(); Contact.VerifySubmitted(); log.Unindent(); }
/// <summary> /// Verifies if Comment is NOT submitted in ContactUs page /// </summary> public void VerifyNotSubmitted() { SeleniumLog log = SeleniumLog.Instance(); log.SaveIndent("Function 2"); log.Blue().WriteLine("Function: VerifyNotSubmitted()"); log.Indent(); log.ResetResult(); slAssert.AreEqual(expected: true, actual: IsExist(ErrorXPath), message: "Verify that Error message is displayed"); slAssert.AreNotEqual(notExpected: true, actual: IsExist(ThankYouXPath), message: "Verify that Thank You message is not submitted"); log.PublishResult(); //In case one of the above assert fails, it doesn't exist straight away log.RestoreIndent("Function 2"); //Ensures unindent back to correct level }
public static void TestSimpleText() { SeleniumLog log = SeleniumLog.Instance(); log.WriteLine("line 1"); log.Indent().Indent().WriteLine("line 2"); log.WriteLine("line 3"); log.Indent().WriteLine("line 4"); log.WriteLine("line 5"); log.WriteLine("line 6"); log.Indent().Pass().Blue().WriteLine("line 7"); log.WriteLine("line 8"); log.Unindent().Unindent().Unindent().WriteLine("line 9"); log.WriteLine("line 10"); }
static void Main(string[] args) { DUMMYSITE_TEST_CASES tests = new DUMMYSITE_TEST_CASES(); tests.TestCase1(); tests.TestCase2(); tests.TestCase3(); SeleniumLog log = SeleniumLog.Instance(); log.Info("Test info"); log.Warning("Test warning"); log.Pass("Test pass"); log.Fail("Test fail"); log.Debug("Test debug"); }
/// <summary> /// Tests if element exists on the page /// </summary> public bool IsExist(string XPATH) { try { SeleniumLog log = SeleniumLog.Instance(); log.Config.OnWebdriverExceptionThrown_LogEvent = false; //temporary disable screenshots and diagnosis on assert IWebElement elem = driver.FindElement(By.XPath(XPATH)); log.Config.OnWebdriverExceptionThrown_LogEvent = true; return(true); } catch (Exception e) { SeleniumLog log = SeleniumLog.Instance(); log.Config.OnWebdriverExceptionThrown_LogEvent = true; return(false); } }
static void Main(string[] args) { try { Example eg1 = new Example(); Example eg2 = new Example(); SeleniumLog log = SeleniumLog.Instance(); bool result1 = log.AreEqual(expected: eg1, actual: eg1, message: "This test should pass ", throwException: false); bool result2 = log.AreEqual(expected: eg1, actual: eg2, message: "This test should fail ", throwException: false); } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadLine(); } }
public void Test1() { SeleniumLog log = SeleniumLog.Instance(); float test = 3.2f; //Check if it matches any of the numbers try { log.Path("AreEual"); slAssert.ResetResult(); slAssert.AreEqual(1.0f, 1.5f, 0.0f); slAssert.AreEqual(1.1f, 3.5f, 0.0f); slAssert.AreEqual(3.0f, 2.5f, 1.0f); slAssert.AreEqual(1.0f, 1.5f, 0.7f); slAssert.AreEqual(1.0f, 1.5f, 0.0f); slAssert.PublishResult(); //You can choose when to evaluate the test and exit the test, so all comparisons above will be made and logged. log.Pass("AreEqual test cases passed"); } catch (Exception e) { log.Fail("Are equal test cases failed"); } try { log.Path("AreNotEual"); slAssert.ResetResult(); slAssert.AreNotEqual(1.0f, 1.5f, 0.0f); slAssert.AreNotEqual(1.1f, 3.5f, 0.0f); slAssert.AreNotEqual(3.0f, 2.5f, 1.0f); slAssert.AreNotEqual(1.0f, 1.5f, 0.7f); slAssert.AreNotEqual(1.0f, 1.5f, 0.0f); slAssert.PublishResult(); //You can choose when to evaluate the test and exit the test, so all comparisons above will be made and logged. log.Pass("AreNotEqual test cases passed"); } catch { log.Fail("AreNotEequal test cases failed"); } }
public void Run2() { FirefoxDriver driver0 = new FirefoxDriver(); SeleniumLogEventListener driver = new SeleniumLogEventListener(driver0); //SeleniumEventListener driver = SeleniumLogEventListener(driver0); SeleniumHomePage Home = new SeleniumHomePage(driver); SeleniumDocumentationPage Doc = new SeleniumDocumentationPage(driver); SeleniumLog log = SeleniumLog.Instance(driver); log.WriteLine("Step 0: Display message"); log.Indent(); Home.Greeting1("Hi there"); log.Unindent(); log.WriteLine("Step 0.5: Display message"); log.Indent(); Doc.Greeting2("Hi there 2"); log.Unindent(); log.WriteLine("Step 1: Go to SeleniumHQ home page"); driver.Navigate().GoToUrl("http://seleniumhq.org/"); log.WriteLine("Step 2: Click on Documentation tab"); Home.DocumentationTab.Click(); log.WriteLine("Step 3: Click on Introduction link"); Doc.Introduction.Click(); log.WriteLine("Step 4: Click on Selenium Tool Suite link"); Doc.SeleniumToolSuite.Click(); log.WriteLine("Step 5: Click on Supported Browsers and Platforms link"); Doc.SupportedBrowsersAndPlatforms.Click(); log.WriteLine("complete."); }
public void Test1() { int count = 0; List <SalesGroup> SalesDepartment = new List <SalesGroup>(); SalesGroup UsedCarSalesGroup = new SalesGroup("Used Cars Group"); UsedCarSalesGroup.SalesPersons.Add(new SalesPerson("Peter Anderson", Convert.ToDateTime("10/05/1980"))); count = UsedCarSalesGroup.SalesPersons.Count; UsedCarSalesGroup.SalesPersons[count - 1].SalesList.Add(new Sales("Toyota Camry 2005", 8000)); UsedCarSalesGroup.SalesPersons[count - 1].SalesList.Add(new Sales("Toyota Camry 2006", 8500)); UsedCarSalesGroup.SalesPersons[count - 1].SalesList.Add(new Sales("Toyota Corolla 2007", 8000)); UsedCarSalesGroup.SalesPersons[count - 1].SalesList.Add(new Sales("Toyota Camry 2008", 9000)); UsedCarSalesGroup.SalesPersons.Add(new SalesPerson("Timothy Williams", Convert.ToDateTime("10/05/1980"))); count = UsedCarSalesGroup.SalesPersons.Count; UsedCarSalesGroup.SalesPersons[count - 1].SalesList.Add(new Sales("VW Polo 2005", 8000)); UsedCarSalesGroup.SalesPersons[count - 1].SalesList.Add(new Sales("BMW 5 series 2006", 17000)); UsedCarSalesGroup.SalesPersons[count - 1].SalesList.Add(new Sales("Subaru Impreza 2005", 9000)); SeleniumLog log = SeleniumLog.Instance(); log.Explore(UsedCarSalesGroup); }
private void SelectFlight(string FROM, string TO, int FLIGHTNUM) { SeleniumLog log = SeleniumLog.Instance(); log.Info("Choose " + FROM + " to " + TO); SelectElement fromSelect = new SelectElement(pom.p1.FromCountry); fromSelect.SelectByValue(FROM); SelectElement toSelect = new SelectElement(pom.p1.ToCountry); toSelect.SelectByValue(TO); log.Info("Click on Choose Flights button"); pom.p1.FindFlights.Click(); log.Info("Choose Flight number " + FLIGHTNUM); pom.p2.GetChooseFlightButton(FLIGHTNUM).Click(); log.Info("Enter payment details"); pom.p3.Name.SendKeys("James Ni"); log.Info("Click on Purchase button"); pom.p3.Purchase.Click(); log.Info("OK Alert"); log.Config.OnWebdriverExceptionThrown_LogEvent = false; WebDriverWait wait = new WebDriverWait(driver1, TimeSpan.FromSeconds(10)); IAlert alert = wait.Until(ExpectedConditions.AlertIsPresent()); alert.Accept(); log.Config.OnWebdriverExceptionThrown_LogEvent = true; log.Info("Click Home button"); pom.p3.Home.Click(); }
static void Foo() { SeleniumLog log = SeleniumLog.Instance(); log.WriteLine("Message from Foo"); }
public void Run() { SeleniumLog log = SeleniumLog.Instance(); log.WriteLine("Run: Start"); }
public void Greeting2(string message) { SeleniumLog log = SeleniumLog.Instance(); log.WriteLine(message); }
public static void TestIndentations() { SeleniumLog log = SeleniumLog.Instance(); int L = 0; log.WriteLine("line 1"); log.WriteLine("line 2"); log.WriteLine("line 3"); log.WriteLine("line 4"); log.WriteLine("line 5"); log.Indent(); log.Indent(); log.WriteLine("line 6"); log.WriteLine("line 7"); log.WriteLine("line 8"); log.WriteLine("line 9"); log.WriteLine("line 10"); log.WriteLine("line 11"); log.WriteLine("line 12"); log.WriteLine("line 13"); log.WriteLine("line 14"); log.WriteLine("line 15"); log.Indent(); log.WriteLine("line 16"); log.WriteLine("line 17"); log.WriteLine("line 18"); log.WriteLine("line 19"); log.WriteLine("line 20"); log.WriteLine("line 21"); log.WriteLine("line 22"); log.WriteLine("line 23"); log.WriteLine("line 24"); log.WriteLine("line 25"); log.WriteLine("line 26"); log.WriteLine("line 27"); log.WriteLine("line 28"); log.SaveIndent("id"); // log.Indent(); log.WriteLine("line 29"); log.WriteLine("line 30"); log.WriteLine("line 31"); log.WriteLine("line 32"); log.WriteLine("line 33"); log.WriteLine("line 34"); log.WriteLine("line 35"); log.WriteLine("line 36"); log.Unindent().Unindent(); log.WriteLine("line 37"); log.WriteLine("line 38"); log.Indent().WriteLine("line 39"); log.WriteLine("line 40"); log.Indent().WriteLine("line 41"); log.WriteLine("line 42"); log.WriteLine("line 43"); log.Indent().WriteLine("line 44"); log.Indent().WriteLine("line 45"); log.WriteLine("line 46"); log.WriteLine("line 47"); log.Indent(); log.WriteLine("line 48"); log.WriteLine("line 49"); log.WriteLine("line 50"); log.WriteLine("line 51"); log.WriteLine("line 52"); log.WriteLine("line 53"); log.WriteLine("line 54"); log.WriteLine("line 55"); log.WriteLine("line 56"); log.WriteLine("line 57"); log.WriteLine("line 58"); log.WriteLine("line 59"); log.WriteLine("line 60"); log.WriteLine("line 61"); log.Unindent().Unindent().Unindent(); log.WriteLine("line 62"); log.WriteLine("line 63"); log.WriteLine("line 64"); log.WriteLine("line 65"); log.WriteLine("line 66"); log.WriteLine("line 67"); log.WriteLine("line 68"); log.WriteLine("line 69"); log.WriteLine("line 70"); log.RestoreIndent("id"); // log.WriteLine("line 71"); log.WriteLine("line 72"); log.WriteLine("line 73"); log.WriteLine("line 74"); log.WriteLine("line 75"); log.WriteLine("line 76"); log.WriteLine("line 77"); log.WriteLine("line 78"); log.WriteLine("line 79"); log.WriteLine("line 80"); log.WriteLine("line 81"); log.WriteLine("line 82"); log.WriteLine("line 83"); log.WriteLine("line 84"); log.WriteLine("line 85"); log.WriteLine("line 86"); log.WriteLine("line 87"); log.WriteLine("line 88"); log.WriteLine("line 89"); log.WriteLine("line 90"); log.WriteLine("line 91"); log.WriteLine("line 92"); log.WriteLine("line 93"); log.WriteLine("line 94"); log.WriteLine("line 95"); log.WriteLine("line 96"); log.WriteLine("line 97"); log.WriteLine("line 98"); log.WriteLine("line 99"); log.WriteLine("line 100"); }
public void Method1(int A, int B, object ds) { SeleniumLog log = SeleniumLog.Instance(); log.WriteLine("Hello World"); }