Can we run TestNG test cases via bat file on a independent machine? (machine which does not have the Eclipse project of the test being run) - selenium-webdriver

I want to create a .bat file to run my TestNG test cases. I should be able to transfer the file to any computer and execute the test cases.
Is it possible to do the above in any way. If yes how?
Thanks

See 4 - Running TestNG on TestNG's documentation page. There you will find information on how to run TestNG from the command line (the same commands can be used in a batch file).
Note that batch files are specific to Windows. If you want to be able to run this on any platform that supports Java and TestNG then I recommend that instead of a batch file you run TestNG programmatically from Java.

Related

Need to convert my Runnable JAR file into a batch file?

I have a working Jar file. It is a Web automation where when I run the code some steps are happening over a URL. (which include pressing of few buttons also).
Now I want this to run when my machine is off. For that i need to schedule a windows job in task scheduler. Is it possible to convert my runnable jar into a batch file and then add a job in scheduler an do the steps when i am offline?
My code looks like this:
System.setProperty("webdriver.ie.driver", "C:\\Users\\x201691\\eclipse-workspace\\Mt_CacheFlush\\exefiles\\IEDriverServer.exe");
WebDriver driver=new InternetExplorerDriver(); driver.get("abc.com");
driver.findElement(By.id("overridelink")).click();
driver.findElement(By.name("password")).sendKeys("abc");
driver.findElement(By.xpath("//input[#value='Login']")).click();
driver.findElement(By.xpath("//div[#class='textMainNav' and normalize-space()='Overview']")).click();
System.out.println(driver.getTitle());
I can't make sense of "convert" a JAR into a batch file. There's no automatic conversion between the two.
If you only want to launch the JAR file from a batch file, you can
path\to\particular\jre\java -jar path\to\archive.jar
From there, you can create a scheduled task (Task Scheduler) that invokes the batch file for whatever criteria you have. IDK if Windows can actually turn the computer on in order to run a task, but if it's already running, you can certainly have the script run whether you're logged in or not.
From what I know, I don't think it's possible to convert a a JAR file into a Batch file. However, if you are insistent on running the JAR file from some form of Batch, you can create an extremely small batch file that will run the JAR file for you, that looks like this:
:start
START C:\<path-to-jar-file>
EXIT
Now, you can go into the task scheduler, and create a task that starts this batch file, then closes itself. I hope this helps!

How to run multiple SpecFlow scenarios using batch script?

I have visual studio 2015 professional edition and in my project there are many feature files and they contain several scenarios of specflow.
I want to run some specific scenarios(having same tag name) of different features using a batch script. So, How do i do that?
It depends which test runner you are using and which flavour Specflow generates your tests in. Basically you write a batch script to call a console tool of your test runner to run the tests. Assuming you are using NUnit you can run them with NUnits runner as described in the documentation other runners will require other stuff
I got the solution, to run specific scenarios we will use common tag name for those scenarios and use the tag in the batch file.
Ex: Features /include:
And after that we use the tag on another batch file(Ex: set arg1=%1). There you initialize the variable for the project. Set the packages for the project and debugger-location.
Then use it in the nunit console and run the .dll file
Ex: nunit-console "%DebuggerLocation%\%Namespace%.dll" %arg1%

making .exe from .bat file tools and solution with dependencies

I have got a solution that uses a .bat file to start. I need to make it a .exe. I have used different tools like [BATch to EXE], [Bat_to_exe_converter], Bat to Exe Converter from [f2ko] which was the most modern one. I need help on the last one which is more sensible to work. or any other solution that makes a working .exe file. Right now, after converting the file to exe according to dependencies the start-up process will not complete. I should mention that the bat file is the Pentaho start-up file.
I have also used IEXPRESS from windows but the error after running the result exe is:
"Error creating process . Reason: The system cannot find the file specified."
Thanks,
Sounds like you need Carte. Carte is a web service that allows remote execution of jobs and transforms.
Carte User Doumentation
You'll probably also need to see this:
Carte as a Windows Service

Make a Single EXE from BATCH and 2 EXEs

I have a script (a.bat) that calls 2 executables (b.exe and c.exe) and I would like to create a single exe that would call a.bat automatically.
Is it possible?
Any simple program to do this?
Ps.: Info: The Exe's do make other files that are deleted in the end
Not directly, no.
The simplest way to accomplish this with off-the-shelf tools is to use an archiver that can create self-extracting archives and allows to specify a file to run after extraction. For example, free Info-Zip tools support an autorun command. WinRAR (commercial) allows to define complex scripts with GUI.
An install engine can be used for the same purpose. For a couple of examples, there are NSIS and Inno Setup (both free).
A (relatively) more complex solution is to write a third executable that will extract payload from its resources and run the batch file. This way you have full control over what happens.
This One:Bat To Exe Converter
It has the "Include" option that can include the exe file
when the compiled exe file run
it will release it
and you can run it!

Can you run AIR apps from command line?

The question ultimately aims at answering this question: can a batch script run an AIR app? The goal is to setup an AIR app on a web server and make it run through batches. I simply have to know whether this is possible by default or not. Thanks.
Oliver Goldman from Adobe posts how to launch an application from the command line:
On Windows and Linux, invoking
AIR-based applications at the command
line is straightforward. On Windows,
inside the application's install
directory you'll find an executable
with the application's name; that's
the thing to run from the command
line. On Linux, the executable is
inside the "bin" subdirectory.
On Mac OS things are slightly
trickier. In Finder, applications
appear to be a single file, but
they're really a folder with with an
extension of ".app" and a particular
interior folder structure. To launch
them from the command line with
arguments, you have to dig into this
structure and find the executable. For
example, to launch an application
named HelloWorld you'd run:
/Applications/HelloWorld.app/Contents/MacOS/HelloWorld
You can also use the AIR Debug Launcher. It allows you to launch the application from the command line based on its application.xml file without requiring it to be installed.

Resources