4

I have built automation framework using Selenium Webdriver, Java, Maven and TestNG. I have setup Jenkins to run any test case easily. Everything running fine.

Now our manager is asking to build web based UI/html where they can access page by hit URL and we need to provide them options to run test cases via html. So here I am confuse that which tool we should use to achieve this requirements?

Based on my research on this I found that if we want to stick with java then we can build web based UI using applet .

Other option is to recode whole our framework into Node JS and Javascript. Do Node JS and selenium are enough to build custom UI in html and allow to run test cases from web based UI.

I know that we should build executable JAR to make it easy but not sure about UI tools which we should use.

  • Don't use Applets, they are deprecated in Java 9 and will be removed in Java 11. Support in Java 8 "will continue through March 2019, after which it may be removed at any time" (see the 2018 Java Client Roadmap Update). – beatngu13 Mar 21 '18 at 13:02
  • what does "to run test cases via html" mean? HTML is just a markup language. Do you mean you want to define test cases in a web UI and use that as input to your test runner? If so, that sounds like a horrible idea. Please clarify your question. – Corey Goldberg Mar 27 '18 at 17:33
2
+100

Jenkins "build now" can run any (Jenkins) test on demand.

Because that URL is fixed (per project), you can create a HTML page with those URLs. If you use wiki, it would be trivial to create such portal to start tests.

"Build now" is just plain URL, like http://jenkins.YOURSITE.com/job/PROJECT/build?delay=0sec but it is required to be POST method (not a simpler GET).

Test results from last build are static URL (....project/lastBuild/) and you don't even need to be logged in to access it. So a page with link to this could be static (or a static HTML page with links to every build can be generated as part of Jenkins pipeline, if you want to add a layer of simplification/obfuscation on top of jenkins)

In discussion (see comments) few more requirements were debated (like time budget max 3-4 months), from which the solution emerged as:

  • Jenkins will run builds as scheduled every X hours. You cannot allow to run build on demand, because it might overwhelm the server
  • We are talking ONLY about how to present Jenkins test results in more user-friendly format. Parsing the standard output and writing HTML page differently.
  • Be prepared that some future Jenkins upgrades will break the format your code relies upon, and page generator will break.

If you have time and desire, this might be a good opportunity to try a language better suited to text parsing and manipulation than Java is. Python would be my first choice. But Java is perfectly capable of handling the task.

  • Do you mean that hit jenkins build URL from html? – Helping Hands Mar 27 '18 at 4:17
  • @HelpingHands Yup, exactly. I added the URL – Peter M. - stands for Monica Mar 27 '18 at 13:22
  • But I tried same and that URL redirects me to new URL where there is processed button. I not yet try with html button. I checked from jenkins it self. please see this : Jenkins – Helping Hands Mar 27 '18 at 13:30
  • Yes, you need to have a FORM HTML element and SUBMIT button, which will execute the POST method for that URL. Let me do some experiments. – Peter M. - stands for Monica Mar 27 '18 at 13:43
  • I see. Let me try with html then. – Helping Hands Mar 27 '18 at 13:51
2

Remark: Applet is a bad idea since they are considered outdated technology by a lot of people and are not supported by some modern browsers. Search around about the issue, but here is the sample discussion.

Fist of all I would think of the particular use-cases we need to support. Either there would be a button to run the entire test suite or it would be a list of single tests which a user is able to select for execution. Basically I think that the exact framework that would build html pages for you is not even such important.

Answering your question I would not re-code everything, but:

  • use some framework to build simple Web applications like https://www.playframework.com
  • that application would let the user choose the tests and press "Execute" button which would:
  • either send a signal to the server to start a system process like you do in your regular flow with Jenkins-Maven
  • or call required maven goals straight from java like it is described here
  • You can also easily integrate your TestNG reports by associating the generated file with the particular test run started from the web application.

This is a quick view on your issue. However, again, you should think of the use-cases, because how effective one or another architecture is often depends on what exactly you'd like to get from your system.

  • Hey. Thanks for your answer. My scenario is like for example given them option/button to run particular test case like run login test case on click on button. Some time we need input as well from use before they run test case. and then we would show progress bar white test case in progress and then show result. – Helping Hands Mar 21 '18 at 7:59
1

You should be able to do this reasonably easily if you define your jenkins jobs using groovy pipeline syntax and install the blue ocean modules into jenkins , its a much slicker interface than previous jenkins pages. https://jenkins.io/projects/blueocean/

You can run each stage of the pipeline on its own and it will use the last built resources. https://jenkins.io/doc/book/pipeline/syntax/

If you add a postbuild section to your pipeline script that archives the result files then the blue ocean view will display the results in a nice tabulated format. Heres someone doing that https://stackoverflow.com/questions/38978295/using-pipeline-groovy-how-can-i-extract-test-results-from-jenkins-for-my-curr/38987837#38987837

heres how it looks and runs https://jenkins.io/doc/book/blueocean/pipeline-run-details/

I've not done this with TestNG but it seems very well supported in jenkins, some of the newer pipeline and blue ocean stuff can sometimes be a little buggy as its quite new , the blue ocean UX seems to appeal a lot better to management types than the standard one so its worth the effort.

pipeline scripts should be stored in version control instead of in the jenkins GUI , its ok to develp them via the jenkins gui but once stable they should be versioned.

  • 1
    you can rerun individual tests from the test result page – Amias Mar 24 '18 at 17:21
  • Hey. Thank you for your answer. I am looking for tools to build custom UI in html and then run tests from html. – Helping Hands Mar 25 '18 at 6:38
  • You could just have a webpage hosted somewhere that has links into your Jenkins system to give you the UI you want. The blue ocean stuff will give you a good starting point for what is possible. – Amias Mar 25 '18 at 8:10
  • Jenkins plugins are non trivial work , if you did consider doing that I would recommend target to blue ocean instead as it's easier and should be supported longer – Amias Mar 26 '18 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.