'How to run HtmlUnit.jar in terminal/command line?

I am searching for a way for testing my webpage using the command line.

My intentions are

  • check an anchor tag is present on the page
  • check the anchor tag href is pointing to the correct(pre-defined) web link
  • Check the anchor tag text is the pre-defined one
  • I should be able to check other tags also like img, script, etc.

After searching, I came across htmlUnit.jar. But I am not getting any proper link on how to run this in the command line.

  • Will I be able to pass the test cases to the jar file? If so, please guide me
  • What is the syntax to run this htmlUnit.jar file in the terminal? I am unable to find any useful documentation

Please help if I can achieve my goal by this file



Solution 1:[1]

HtmlUnit is a library, you have to write your own program using HtmlUnit for your use case.

Another option is to use Wetator (www.wetator.org). Wetator is

  • based on HtmlUnit
  • runs from the command line
  • can perform the different asserts you like to do
  • generates a nice report (and also a return code if at least one assert fails)

(Ok, i'm the person behind HtmlUnit and Wetator so maybe i miss some other option)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RBRi