CHAPTER 15
Test Data
Gathering test data is an important but often neglected activity. With the power of C# programming, testers now have a new ability to prepare test data.
Get date dynamically
// assume today is 2014-12-29String todaysDate = DateTime.Now.ToString("MM/dd/yyyy");Console.WriteLine("todaysDate = " + todaysDate);driver.FindElement(By.Name("username")).SendKeys(todaysDate); //=>12/29/2014
A more flexible way is to write some helper functions to return common dates.
Today("dd/MM/yyyy"); // => 29/12/2014Tomorrow("AUS"); // => 30/12/2014Yesterday("ISO"); // => 2014-12-28public static String GetDate(String format, int dateDiff) ...
Get Selenium WebDriver Recipes in C#, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.