Scaladays 2014 introduction to scalatest selenium dsl

Selenium is a technology used to test web sites by firing up a browser and then interacting with a web site. It can be used from a number of languages - Java, Python, Ruby. Scalatest 2.0 introduced a DSL which simplifies the writing of tests in Selenium. More importantly, it simplifies the process of reading and understanding the tests. It becomes easier to walk through a test with a semi-technical person.

We present a introduction where we test an application with heavy use of Javascript using the DSL, along with advantages and disadvantages of the approach that we took. We also look to the future to see what could be done better.

3.
GOALS
• Present the Selenium DSL
• Show how it simplifies the writing of selenium tests.
• Show how it can be used to test a javascript heavy application
• Show how it can be integrated with other tests to make more useful
integration tests
• The future, well what I would like anyway

4.
SELENIUM
• Selenium automates browsers.
• Firefox, Chrome, Internet Explorer, Safari, Opera, HtmlUnit
• Selenium has interfaces for Java, Python, Ruby, etc.
• We'll be looking at from the point of view of testing
• But we could use it for other stuff – automation of administration for example.

27.
OUR CONTEXT
• Lots of legacy code, partially tested with selenium in Java / Python.
• Lots of new code, which has been tested with Scalatest selenium DSL
• A simple click on a web page can have effects way beyond CRUD
• Selenium used for testing pure HTML, GWT, Angular JS applications

28.
OUR EXPERIENCE
• DSL is good for walking through a test – clearer and more readable than the
Java equivalent
• We have tests written by "developers" and "testers"
• Consistent tests – we use Scalatest for unit tests, UI tests and integration tests.
• Selenium DSL is integrated into Scalatest
• Always have ids on elements
• Our integration tests work with heterogeneous actions in the same test:
• we can perform an action in the Browser,
• then check call rest service,
• then check the database,
• call a command via ssh on a remote machine.

29.
WHAT WE'D LIKE TO IMPROVE
IMPLICIT EVENTUALLY
eventually {
click on "userEdit_2"
}
eventually {
textField("foo").get.value should be ("bar")
}
eventually {
click on "btn"
}
eventually {
textField("baz").get.value should be ("flobble")
}

30.
WHAT WE'D LIKE TO IMPROVE
SLOWING DOWN
eventually {
click on "userEdit_2"
}
eventually {
textField("foo").get.value should be ("bar")
}
eventually {
click on "userEdit_2"
}
eventually {
textField("foo").get.value should be ("bar")
}