I'm looking for a Java API which allows me navigating through HTTP Pages and read the content, just like a Browser. The difficult part of it is that navigation includes performing some actions (e.g. list box selection and submit) and JavaScript interaction (e.g. Yes or No dialog). Is there such API which can be used for this purpose ? Thanks!
Asked
Active
Viewed 629 times
0
-
2http://www.seleniumhq.org/ . It sucks, but there's nothing better – Sean Patrick Floyd Dec 02 '14 at 08:42
-
2[HTMLUnit](http://htmlunit.sourceforge.net/), [Selenium](http://www.seleniumhq.org/) – BackSlash Dec 02 '14 at 08:42
-
See also [Arquillian Graphene](http://arquillian.org/modules/graphene-extension/) and [js-test-driver](https://code.google.com/p/js-test-driver/) to some extent. – lexicore Dec 02 '14 at 08:59
-
Thanks for your reply. I'll use then HTML Unit as I have knowledge of JUnit. – user2824073 Dec 02 '14 at 09:14
1 Answers
2
If you are willing to diverge a bit from Java and enter the realm of Groovy, you could give a try to Geb and Spock.
Groovy code compiles into Java code and runs into a JRE. Geb is effectively a domain specific language that allows you to model HTML pages with a syntax that is more friendly and intuitive than Selenium. Geb and Spock work well together with can make your life a bit easier. For sure, the is a learning curve, but in the end your tests are much easier to write, read and maintain.
For some learning material you could also have a look at this question.

Community
- 1
- 1

user1485864
- 499
- 6
- 18
-
Thanks for the useful link and suggestion. As I need a quick implementation, I'll follow the advice from @BackSlash who suggested HTMLUnit – user2824073 Dec 02 '14 at 09:15
-
@user2824073 Be careful what you define as "quick". The initial cost of moving into Geb/ Spock can be absorbed after a couple of weeks. In other works, if you plan to invest more that two weeks for browser testing, then it is probably worth it to make the move. – user1485864 Dec 02 '14 at 09:46