1

I am relatively new to Selenium WebDriver and a self learner. I have created a webDriver project which consists of different packages and have made use of Page Factory concepts extensively. I use TestNg framework to run the suite to generate my report. So my test cases are also following the TestNG framework concepts. Now my team wants to use my script to be run at every build to test the sanity. The build team just wants to run my whole script by just a click. It can be shell script command or .exe or jar. Build team uses linux m/c and they dont have Ecplise , TestNg installed in their machine. Their intention is whenever build is given they want to run my script by just a click or a command in Command Prompt.( it has to be that simple for them) and a report should be generated in some location in hdfs

My script runs on FF version 32 and Selenium webDriver 2.44.0

Would really appreciate if someone could give me a solution that actually works for my requirement.

I found a similar query from someone but i am not sure if the answer still suits.
How to make Java executable Jar file of WebDriver project

Could somebody please give me a solution. Or the solution mentioned in the above link stil is the best?

Regards

Community
  • 1
  • 1
Pringa
  • 91
  • 2
  • 6

2 Answers2

0

There are few ways to do it:

  1. Use CI tool (Jenkins): You can set up your project in Jenkins and it will allow you to run the project in single click. Jenkins also provides you an option to run the tests periodically so you can configure it in such a way that it will always get executed after certain time period.Jenkins is also capable to trigger the execution if there is any changes in source code of tests. I'd suggest to use this tool. https://jenkins-ci.org/

  2. Use .bat or .sh file: I am not sure if you are using any build tool like ANT or Maven, if you are using any one of them then you can write a .bat or .sh file to run the tests. ANT

If you are not using any build tool then start using, it will help to run the tests in simplest way.For me to run entire suite, I just type below command in terminal from root directory of project

ant run -Dsuite=all
  1. If you are more concerned about system configuration for e.g. the system which will be used by build team does not have a specific version of browser or specific required library. Then I'd suggest to keep all essentials like browser installation files, libraries in your project directory. This is not a good practice but yes it will help others to run the tests smoothly.
Priyanshu
  • 3,040
  • 3
  • 27
  • 34
  • Thank u soo much for a prompt reply . I wlll surely try what you have mentioned and get back if am still stuck :) – Pringa May 12 '15 at 04:29
  • HI Priyanshu , can you please tell me who to do this using Jenkins... more details please.. i am not familiar with the tool – Pringa May 13 '15 at 09:09
  • @Prings Do u use any build tool like ANT or Maven? If you not then explore it and add it in your project. This will be helpful for setup Jenkins. – Priyanshu May 13 '15 at 10:11
  • Hi, what my build team actually requires is, using any script , shell scripting etc , just install my Selenium Script. No jenkins and Ant tool anything. :( My Build Team manager gave this as the example : when u have a .exe file , any system you can install. it will by itslf install all dependencies if any. It will just have few pre-requisite. Thats the same way he also expects from my Script. He doesnt want to use any jenkins or tools cos Client side wont have it. He should be having my script as a portable form , using shell script call the script and just Run it... Is it possible ? – Pringa May 14 '15 at 04:30
0

I would suggest just exporting a jar file for your project. All the libraries will be packaged together in the jar files(including TestNG) and you can simply double click on the jar file to start your tests.

External resources (if any), will have to be available for the jar file though. So, you can provide the jar file and the external resources together. The external resources might include your test data (if any) or Portable Firefox(if you are using the portable version).

Steps:

  • Right click on Project -> Export -> Runnable jar file
  • Give a name and file path for the jar file
  • Select option - Extract required libraries into generated JAR
  • And Finish

Troubleshooting:

Check the java version for the machines that you will be running your jar file on. Programs compiled with java 7 will mostly not run if the machine has java 6. Either compile with java 6 or update the jre on the target machines.

If the jar file does not launch, try using Jarfix.

LittlePanda
  • 2,496
  • 1
  • 21
  • 33
  • Thank you.. I shall try this as well. and get back to you – Pringa May 12 '15 at 09:15
  • Hi , I am not able to create runnable Jar , its asking for "Select a 'Java Application' launch configuration to use to create a runnable JAR." , the drop down that provides input is some othr java projects. which is not connected to my current project. My project is a Dynamic Web Application project. and my script as @Test annotation used and there is no main method. – Pringa May 13 '15 at 05:57
  • I don't know how Dynamic Web Application projects work, you just have to select the launch configuration that you usually use to run your project. In case of TestNG, the config type is TestNG, for Java the type is Java Application. – LittlePanda May 13 '15 at 07:25
  • Hi, what my build team actually requires is, using any script , shell scripting etc , just install my Selenium Script. No jenkins and Ant tool anything. :( My Build Team manager gave this as the example : when u have a .exe file , any system you can install. it will by itslf install all dependencies if any. It will just have few pre-requisite. Thats the same way he also expects from my Script. He doesnt want to use any jenkins or tools cos Client side wont have it. He should be having my script as a portable form , using shell script call the script and just Run it.. Is it possible ? Plz help – Pringa May 14 '15 at 04:30
  • Make a runner(Main method) class in your project that calls all the tests one by one. Export your project as a runnable jar file. Distribute this jar fle to your team(just package it with all the test data). I usually export the jar file and distribute jar+test data as a whole package. You say, you have a dynamic web project, try this - http://stackoverflow.com/questions/5993507/export-a-web-project – LittlePanda May 14 '15 at 06:03
  • hey i have again posted my query in http://stackoverflow.com/questions/30316921/how-to-make-webdriver-testsuite-created-in-windows-machine-to-run-in-a-linux-box could u read and help. I think i have made it more clear in other query – Pringa May 19 '15 at 04:45