Testing by hand is easy but takes a lot of time. At Drivr (drivr.com) we try to automate everything including testing before releasing our applications. I will share our experience how we have reached zero manual testing after releases and how we are sure that our applications still work, CSS changes haven't broken layout, and our web sites still look good on different browsers and on mobile devices.
5. IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.google.com/");// Find the text input element by its name
IWebElement query = driver.FindElement(By.Name("q"));// Enter something to search for
query.SendKeys("Cheese");// Now submit the form. WebDriver will find the form for us from the
element
query.Submit();// Google's search is rendered dynamically with JavaScript.// Wait for the page to
load, timeout after 10 seconds
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until((d) => { return d.Title.ToLower().StartsWith("cheese"); });// Should see: "Cheese -
Google Search"
System.Console.WriteLine("Page title is: " + driver.Title);//Close the browser
driver.Quit();
Sample code
11. Challenge 3: Data changes in
database
Don’t rely on data which can change
Have a “save” corner for your data
Or create a test data automatically
Or… have a separate test environment
12. Challenge 4: Simulation of different
situations
Special data config on DB
Data stubs in API
Data mocking on client side (later)
13. Challenge 5: Test stability
“Thread.Sleep()” is your enemy
Use WebDriverWait instead
// Google's search is rendered dynamically with JavaScript.// Wait for the page to load, timeout after 10
seconds
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until((d) => { return d.Title.ToLower().StartsWith("cheese"); });
Retry, retry, wait and retry again
Do it simple!
14. Challenge 6: Long running tests
Run tests in parallel
Split big test to a few smaller tests
Replace with JavaScript unit tests where
possible (later)
1000 unit tests takes 2-3 seconds
4-5 UI tests takes one minute
15. Challenge 7: Run tests in Production
Choose some tests to confirm your release to
production
We do not change any data
16. Challenge 0: Automation oriented
culture
Every team member must agree on automated
tests
Test is as much important as feature is
Don’t leave tests for “next sprint”
Do not release if even single test fails
Be prepared for long learning
18. Cross platform testing
Selenium supports many browsers + iOS and
Android
Run different OS for Selenium?
Sauce Labs
http://saucelabs.com
BrowserStack
http://www.browserstack.com/
22. JavaScript unit tests
Jasmine testing framework
http://pivotal.github.io/jasmine/
AngularJS + HTTP mocking
http://docs.angularjs.org/api/ngMock.$httpBackend
Karma as tests runner
http://karma-runner.github.io/
E2E testing with
AngularJShttp://docs.angularjs.org/guide/dev_guide.e2e-testing
Thousands of tests in a seconds
Much stable than UI tests
Much easier to write!
23. Final word
Test automation is continuous process
Be prepared for long learning
Screenshot comparison rules!
AngularJS and Javascript unit testing is
awesome!