I was wondering if I could get some advice regarding automating the scheduling of selenium test cases in java. I have a set of test cases written in Java with selenium and maven that go onto a website, clicks a few buttons which in turn downloads a daily file.
I use AutoItX do interact with the download window to choose my save location and type a name etc.
The code works perfectly for when I execute it normally in Intellij. However I now need to find a process that can kick the build of the code off automatically.
I thought about using Jenkins however it is unable to access my download folder/file system when it comes to downloading files. I also thought about setting a task scheduler on my system to run a batch file that would kick off the project but I cannot guarantee the system will always be on and logged in.
The question I have is: Is there a way to grant jenkins a way to interact with my file system or is there an alternative tool which will allow me to do this.
Or am I missing a config step that will allow me to accomplish what I want?
Thanks in advance.
If you are running Jenkins as a windows service you can allow it to interact with desktop and run it as a user with elevated privileges. e.g.
You can schedule Jenkins job that will be triggered at certain intervals. e.g. you may want to run it at 9PM then Build periodically is the option you may want to use.
Related
I want to execute a Jar file using javax swing GUI with 1 radial option, a file selector and a button. The goal is to be able to automate the jar through CLI and select the radial option, file and then click the button.
I do not have access to edit the source of the jar
Is this possible?
You can look up JAuto, which is a JVMTI agent that is capable of expose UI widget attributes such as class names, screen coordinates. You talk to JAuto by sending a command to a named pipe. It responds by writing a file. A communication scheme like this works in bash scripts.
With the help of xdotool as an input simulator, you can achieve automation under the Linux X11 environment, inside a docker container.
Although depending on the complexity of the Java app, automating it in a headless manner can also be time-consuming. You may also need a VNC setup to inspect program behavior. Checkout this project IBGA and see how it uses JAuto and xdotool to automate a program.
Disclaimer: I'm the author of both JAuto and IBGA.
I am working in with Java in intelliJ and have a testSuite that I would eventually like to be able to automatically run, export test results to file, and email those results to my boss. The test runs and the e-mail sends with the attachment. I just can't seem to figure out if there is a certain method that I can implement to do such a thing.
You can achieve this by installing a continuous integration server, which will monitor your version control system, run the tests every time you commit code, and send the notifications according to your configuration (for example, by sending an email to your boss if that's what you need).
Popular continuous integration servers include Jenkins and TeamCity.
I have a Java application that lives in the system tray that I compile to a executable jar file. I would like to add the option within my program to add to the system startup items.
As I do not know of any uniform way to do this for all operating systems I assumed I would have to write code to do it for each one I intend to support so I started with Windows.
When I attempted to add it to the registry at [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] using the code available here I discovered that under Windows 7 and 8 unless I have administrator privileges (by running from an elevated command prompt) my edits to the registry do not apply.
Then I spent a day trying to figure out how to get the Jar to relaunch itself with admin privileges before I gave up on that hacky workaround.
Can the task I'm trying to achieve even be accomplished and if so how?
For the most part, you're actually looking to add the feature of auto starting on user login, rather than on system startup. For windows, if you add the registry entry under:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
This location does not suffer from permissions issues when run as an ordinary user, and has been supported for a long time under Windows (I'm thinking Windows 95 time frame here), so should be a safe change across all systems.
For Linux, assuming that the operating system is following the Open Desktop AutoStart specification, then you need to create the appropriate .desktop file in $HOME/.config/autostart/ and it should autostart on login in that case.
For Mac OS X, you need to create a launch agent plist in $HOME/Library/LaunchAgents. The Daemons and services documentation details how to construct this file.
Working around user privileges is not a good idea. The registry entry is the preferred way to go. Also keep in mind that the jar by itself is not executable, it requires the jvm, so what you might want to do is use a wrapper and register that.
I wish the run command (usually default to CTRL+F11 combination) of a Java project (and C++ if you know it too) to automatically close the previous process (or all processes, if it's easier) started by it before it runs a new instance.
In short, running a project should also close previous app instance. Is it possible?
Maybe it's possible to add code to the app itself, and disable it once I don't need it anymore? I want it since it's annoying to close the app each time. I don't need so many instances of the app.
In Eclipse Neon go to Window -> Preferences -> Run/Debug -> Launching and in the Launch Operation section check:
[X] Terminate and Relaunch while launching
Easier said than done. I suggest you terminate the process yourself by clicking on the little red stop icon in the console or by terminating the main thread from the threads view in the debugger perspective.
That's not possible with Eclipse built-in features. The easiest way to automate this seems to be
Install the launch group feature from CDT (you only need the mentioned feature) or the EclipseRunner plugin. They allow creation of "batch" launch configurations.
Create an external run configuration with a "kill" command (depending on your operating system), which can kill your application process based on the application name.
Create a batch launch group with one of the two plugins mentioned above, where the "kill" configuration comes first and your normal launch configuration comes second.
I have created a Java application which needs to run as a service. For service wrapper I tried using tanuki and other wrapper softwares.
Now, my application does run as a service - however, it runs as a service under SYSTEM and not under currently logged in user.
My application has a UI, which does not show when the application is running as a service. I doubt that this has happened because the service is running under SYSTEM and not under currently logged in user.
When I run the application (without installing it as a service), the UI does show up and I could see the java process running under the current user's id, whereas it runs under SYSTEM when installed as a service.
Now, there is nothing to my application if there is no UI. I need to application to run as a service when the system boots up and the UI needs to show up as well.
Has anyone tried to do what I am doing here and has faced a similar issue. If so, how did you go about resolving it?
Is there a different wrapper service that I could use and not have this issue.
Tanuki's documentation does explain setting a java application as a service, but does not talk about a java applicaiton with a UI and running it under the currently logged in user.
Update
Just so that folks here could get a bit more idea as to what is it that I am trying to accomplish - the behavior that I am trying to have with my app is similar to how Dropbox or Yahoo Messenger or any other software has which starts with Windows boot and continues to run in the background, allowing the users to interact with it using the system tray icon. So basically all of this has been built in Java/Swing. Now when it has come to deployment of the app - I can run it standalone but running the jar file or by creating and running an executable wrapper for it. However, I want the software to start with Windows boot and continue to run as a service in the background, while allowing the user to make changes and interact with it via lets say bringing up the UI from a system tray icon that it sets.
As of now, it does run as a service successfully. It performs all the actions that it ideally should - there just is no system tray icon to bring up the UI and make changes to its configuration.
Update - 2
Ok.. I tried advanced installer and it does wrap up everything for me to generate an exe installer for windows. Now all I need is to auto-start the software. Can anyone help me with this? I don't see an option in Advanced installer to automatically have the program add itself up in the auto-start.
Link to tanuki's doc http://wrapper.tanukisoftware.com/doc/english/faq.html
Rohan,
Please take a look at the following page:
http://wrapper.tanukisoftware.com/doc/english/prop-ntservice-interactive.html
You will need to mark the Service as interactive and then run as the SYSTEM user in order to get your GUI to show up on the first logged in desktop.
The problem is that Microsoft changed what services are allowed to do starting with Windows 2008 and Vista. This means that starting with these versions, the GUI will always show up on a sandboxed desktop which the user will need to switch over to.
If you want to show a GUI on all desktops, in all versions of Windows, you will need to run the JVM within the desktop.
Cheers,
Leif
I wanted to comment on your question, but I don't have enough reputation to do it. So I'm misusing the answer function now.
I have a similar problem. I used the tanuki wrapper for a while now on a Windows XP machine and the Swing GUI was shown to all users who logged in.
Now I migrated to Windows 2008 Server and configured the current version of the tanuki wrapper like this:
wrapper.ntservice.interactive=true
wrapper.ntservice.hide_console=true
(see documentation here and here)
The Windows service runs under the LOCAL SYSTEM account.
But the GUI is still not shown. Did you find any solution to the problem?
Don't think you should have a UI with a service. Put it in the startup group instead ?
What's does the UI and application do?