Anyone knows a good tutorial for a beginner in Selenium
and jUnit
?
I already have a background in unit testing
and acceptance testing
(RSpec and Capybara on Rails 3), and now I'm starting this new project with JavaEE and I'm looking for a quick start with both of this technologies.
Thanks.

- 19,463
- 19
- 103
- 140
-
1I found TutorialsPoint very helpful: http://www.tutorialspoint.com/junit/index.htm + http://www.tutorialspoint.com/selenium/index.htm. Also, for Selenium nothing beats their learn-by-example method on their own website - http://www.seleniumhq.org/docs/03_webdriver.jsp – Andrejs Feb 24 '16 at 22:01
2 Answers
I'm doing some extensive reading/research about this subject so I'll share the good articles/slidshows/books/answers I found:
http://www.qaautomation.net/?cat=7 : I used this website & I thought it was pretty good (for Selenium anyway).
http://www.vogella.com/articles/JUnit/article.html : just had a look & seems interesting
wakaleo: junit-kung-fu-getting-more-out-of-your-unit-tests : a great overview on some key JUnit features
testing-a-web-application-with-selenium-2/ : Selenium + JUnit
SO question: how-to-use-junit-and-hamcrest-together (TBC) Be careful when using JUnit & Hamcrest together: if Hamcrest has a version greater or equal to 1.2, then you should use the junit-dep.jar. This jar has no hamcrest classes and therefore you avoid classloading problems.
Moreover regarding Hamcrest, it states on its google code page that "Hamcrest it is not a testing library: it just happens that matchers are very useful for testing". Hence you may want to look into FEST "whose mission is to simplify software testing".
SO question: junit-one-test-case-per-method-or-multiple-test-cases-per-method
SO question: selenium-junit-tests-how-do-i-run-tests-within-a-test-in-sequential-order
tomek kaczanowscy's blog: author of "Practical Unit Testing" (see below)
This book came out recently (Published in 2012 vs lots of out-of-date books) & it looks very interesting: Practical Unit Testing with TestNG and Mockito by Tomek Kaczanowski
Finally, you probably want to look at a mocking framework (ie. Mockito, JMock, EasyMock):
-
You may want to look at TestNG, seems better than JUnit from what I read – Adriano Sep 12 '12 at 14:10
I would suggest that you use TestNG instead of JUnit. TestNG offers you more options and possibilites how to run your tests and in which order especially (something Junit can't). Here some useful links.
- TestNG Doc,
- SeleniumHQ here you can find the first guides
- SeleniumApi
- CssSelectors very usefull for finding elements without id/name, better than xpath
Hope that helps

- 2,112
- 2
- 23
- 42