How to convert selenium scripts as standalone .exe file?

9,563 views
Skip to first unread message

Hemapriya Rajendran

unread,
Feb 6, 2013, 9:47:08 PM2/6/13
to seleniu...@googlegroups.com
Hi,

Is it possible to convert Selenium scripts into the standalone exe file?
I am using TestNG using Java for selenium. Can you please tell me how to make it as standlone exe file? means running outside the eclipse.

Please do the needful.

Thanks,
Hemapriya R

Krishnan Mahadevan

unread,
Feb 6, 2013, 11:36:47 PM2/6/13
to seleniu...@googlegroups.com
Why dont you try converting it as an executable jar ?

That way you could execute it by doing java -jar myjar.jar or by merely double-clicking on the jar name. 
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/uCiOqlfZ-w4J.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

Hemapriya Rajendran

unread,
Feb 7, 2013, 3:30:25 AM2/7/13
to seleniu...@googlegroups.com
Can you please explain how to do that?

I have my code which is executable in Eclipse.

How to make it using the mentioned jar to run outside the Eclipse?

Please do the needful.

thanks,
Hemapriya R


On Thursday, February 7, 2013 10:06:47 AM UTC+5:30, Krishnan wrote:
Why dont you try converting it as an executable jar ?

That way you could execute it by doing java -jar myjar.jar or by merely double-clicking on the jar name. 

On Thursday, February 7, 2013, Hemapriya Rajendran wrote:
Hi,

Is it possible to convert Selenium scripts into the standalone exe file?
I am using TestNG using Java for selenium. Can you please tell me how to make it as standlone exe file? means running outside the eclipse.

Please do the needful.

Thanks,
Hemapriya R

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/uCiOqlfZ-w4J.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

David

unread,
Feb 7, 2013, 1:55:29 PM2/7/13
to seleniu...@googlegroups.com
It can get a bit tricky going the JAR route, you might have to retrofit your Java test(s) to have a main method so that you can execute the JAR as Krishnan mentions. Otherwise, you would also have to specify which class method you want to run when executing the JAR like

java -jar myjar.jar com.yourpackage.name.ClassMethodNameToExecute

or

 java -cp .:myjar.jar com.yourpackage.name.ClassMethodNameToExecute

Your tests may not just run out of the box, and you may have to write a Java wrapper framework class so that it can execute the whole suite, etc. when calling the JAR. I don't know if anyone has done such with JUnit/TestNG based tests in a JAR. That might be a starting point do a web search for executing JUnit/TestNG tests from a JAR, etc.

Also, for EXE option, that's possible if you do it with the .NET bindings and compile the test collection as an EXE than as tests to be executed via NUnit, etc. And again, that requires creating wrappers or modifying tests to operate as EXE than via NUnit, similar to Java JAR approach.

On Thursday, February 7, 2013 12:30:25 AM UTC-8, Hemapriya Rajendran wrote:
Can you please explain how to do that?

I have my code which is executable in Eclipse.

How to make it using the mentioned jar to run outside the Eclipse?

Please do the needful.

thanks,
Hemapriya R

On Thursday, February 7, 2013 10:06:47 AM UTC+5:30, Krishnan wrote:
Why dont you try converting it as an executable jar ?

That way you could execute it by doing java -jar myjar.jar or by merely double-clicking on the jar name. 

On Thursday, February 7, 2013, Hemapriya Rajendran wrote:
Hi,

Is it possible to convert Selenium scripts into the standalone exe file?
I am using TestNG using Java for selenium. Can you please tell me how to make it as standlone exe file? means running outside the eclipse.

Please do the needful.

Thanks,
Hemapriya R
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/uCiOqlfZ-w4J.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

yasin...@gmail.com

unread,
Dec 13, 2013, 5:47:28 AM12/13/13
to seleniu...@googlegroups.com
Is it possible to compile an exe from code generated by selenium with python or php and have it work on another computer (without installing any additional frameworks/wrappers)?

If so, please tell me how or provide a url so I can learn more.

Thank you!

David

unread,
Dec 13, 2013, 5:17:13 PM12/13/13
to seleniu...@googlegroups.com
PHP - try these? I've not done this myself


Python - there may be several options, I'ved used py2exe with success before, though that was not for Selenium, but I'm sure it could work for Selenium too.


For out of the box executable Selenium program support, your best option is .NET (C#), because that always compile to executables by default and any accompanying assembly DLLs (relative to the executable, or in .NET system path). So if all that is packaged in a "portable" application folder, then as long as the user has the matching .NET framework installed (e.g. like JRE installed), then it will run just fine with a double click or execute from command line. No special steps like Python, PHP, etc. to get a binary executable.

You could also convert Selenium scripts in Ruby or Perl to binary executable too, those have options too. For any language just search for "language name 2 exe" for available options.

Christian LeMoussel

unread,
Dec 14, 2013, 12:59:56 PM12/14/13
to seleniu...@googlegroups.com
Use WebDriver with C# .NET 

yasin...@gmail.com

unread,
Dec 16, 2013, 7:45:49 AM12/16/13
to seleniu...@googlegroups.com
Thanks for the help, David and Christian.

I'll explore those options. I like to verify that this allows me to create an exe of my macro?

For example, if my macro were to click 3 different buttons inside the browser, the exe would click three different buttons by itself instead of launching a selenium instance to click three buttons.

Christian LeMoussel

unread,
Dec 16, 2013, 1:35:47 PM12/16/13
to seleniu...@googlegroups.com
Yes quite.

in C# I use WebDriver libraries, available on NuGet : Selenium WebDriver & Selenium WebDriver Support Classes


David

unread,
Dec 16, 2013, 1:41:36 PM12/16/13
to seleniu...@googlegroups.com
No the options Christian & I provide won't work in your case. Executing Selenium code whether an exe or not will always launch a new browser. And as of now, Selenium doesn't really support attaching to an existing browser session. If that did work at all, its more for IE I think.

What you might be able to do is create macro code snippets (say organized into a class library of methods) and then execute those when needed from an interpreter shell. Using this approach, you open up a Python/Ruby/PHP (or maybe .NET via Mono or Java via Beanshell) shell, then fire up the Selenium browser session (executing basic code or one of your macro methods), then perform any manual steps you want, and when you want to execute automated code again, go back to your interpreter shell window (that you've kept open all this time) and run another macro method. This gives you the best of both worlds approach to do manual actions in same Selenium session and run any macro code you want (assuming you've organized it for easy execution like in class library methods). 

And for Python/Ruby, you even have option to start this off as a script (or executable, if compile script to exe) by running script/executable to launch Selenium browser, and then the script forces a breakpoint in code that forces/breaks you into the interpreter shell for debugging (meaning you don't need to open shell first). With the shell open now, you can continue with manual steps and go to shell to execute the macro code. And if you've imported/referenced the macro library in the main script and compile to exe, I would think it would all be bundled in the package together (not a single exe, but exe + accompanying files/DLLs in same folder) that you can distribute. This option is not available for Java and .NET, not sure about PHP, Perl.

David

unread,
Dec 16, 2013, 1:44:02 PM12/16/13
to seleniu...@googlegroups.com
Christian, I think the poster was referring to running Selenium code against an existing open browser as "macro" code like in MS Office/Word/Excel against an open document and not to start a new Selenium browser session just to run the code. Like I have browser open now, run exe, and it should do things against my currently open browser.

Christian LeMoussel

unread,
Dec 16, 2013, 3:00:14 PM12/16/13
to seleniu...@googlegroups.com
David,

In C# with Roslyn I make a library that wraps around Selenium to simplify web automation. 
It's a framework  with many of the technicalities to compil & execute script  code. 

For example: Here is a my script. 

webinteraction.Driver.Navigate().GoToUrl(webinteraction.SiteUrl);

webinteraction.WaitForElement(By.LinkText("register")).Click();
// Choose username
webinteraction.WaitForElement(By.XPath("//form[@id='creator']//input[@name='user']")).SendKeys(username);
// Email
webinteraction.Driver.FindElement(By.Name("email")).SendKeys(email);
// Hide email address from public
webinteraction.Driver.FindElement(By.Id("hideEmail")).Click();
// Choose password
webinteraction.Driver.FindElement(By.Name("passwrd1")).SendKeys(password);
// Verify password
webinteraction.Driver.FindElement(By.Name("passwrd2")).SendKeys(password);

// Image Captcha
string sCapchaImageText = webinteraction.getCaptchaImage(By.XPath("//*[@id='verificiation_image']"));
webinteraction.Driver.FindElement(By.Name("visual_verification_code")).SendKeys(sCapchaImageText);


Muzzamil

unread,
Dec 16, 2013, 10:49:11 PM12/16/13
to seleniu...@googlegroups.com

Hi hema,

If you are using Ant with TestNg  then you can create ".Bat"  file and  you can  run your all test cases without using eclipse.

Thanks,
Muzzamil

--

Avikash Gorka

unread,
Dec 16, 2013, 11:47:18 PM12/16/13
to Selenium Users
try using FAT Jar Pluggin in Eclipse to make Executable Jar File

Thanks & Regards,

Avikash Gorka
Test Analyst, AON Hewitt



khairaj pamnani

unread,
Feb 8, 2014, 4:21:33 PM2/8/14
to seleniu...@googlegroups.com
Hi,

To create exe jar using eclipse export option..you need a program with main class. So first you have to create a main class which will call your rest junit script.
import following class
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
And use following code inside main class to call your programe:
Result result = JUnitCore.runClasses(<classtoexe>.class);
Thanks!

Shawn Knight

unread,
Feb 9, 2014, 10:33:38 PM2/9/14
to seleniu...@googlegroups.com
Why not just use maven or ant to run the script? IMHO, a jar or exe file is way over the top with increasing complexity with little to no gain.
Reply all
Reply to author
Forward
0 new messages