December 2015
Intermediate to advanced
192 pages
3h
English
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) ...
Read now
Unlock full access