Applications/processes ran using Java 8 on Windows are not visible - java

This has been making me work overtime and I still don't have much clues. I have a web application that is locally installed (pseudo-desktop app) that does the following:
Starts an SSH tunnel
directly runs ssh if on Mac OS X
uses PuTTy executable if on Windows
Opens Firefox or Chrome configured to use Socks5 proxy using the tunnel (localhost:port) via Selenium webdrivers.
For 1:
I have used both Runtime.getRuntime().exec(command); and Process proc = new ProcessBuilder(arguments).start();, and even gave Desktop dt = Desktop.getDesktop(); dt.open(f); a try. But nothing happens, no command prompt opens.
For 2:
I have tried using both Firefox:
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.socks", "localhost");
profile.setPreference("network.proxy.socks_port", 8088);
driver = new FirefoxDriver(profile);
And Chrome:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--proxy-server=socks5://localhost:8088"));
driver = new ChromeDriver(capabilities);
But similar to 1, no firefox or chrome windows open.
Note that this application works perfectly on Mac OS X Mavericks.
After several hours of debugging, I noticed that the processes are there. All the processes, from PuTTy, to Chrome, to Firefox. There were a lot of those already running in the background. The odd thing is that the user column of these processes is set to SYSTEM, while the normal browser sessions, for example, the user is set to "IT", which is my current Windows user account.
I have been trying to manually change the user in which these processes are invoked, but no luck so far.
So apparently, my application works in Windows as well, just not as I intended. All the processes, regardless if it's a command line script or a desktop application like firefox or chrome, they just don't appear but they run in the background under the user "SYSTEM". And I don't have any idea why. It sure doesn't look like it's supposed to be the default behavior. So if anyone have any idea, I'd really appreciate it.
Thanks.

Finally I was able to fix this! Thanks to this article (from a seemingly not related case):
Most Windows services -- including those run with the option "Allow
service to interact with desktop" in Windows XP and Vista -- do not
have access to many of the computer's resources, including the console
display. This may cause Automated GUI Tests to fail if you are
running Apache Tomcat as a Windows Service and are doing any GUI
testing. This is true at least for AWT and Abbot frameworks.
This limitation can be resolved by not running Tomcat as a Windows
Service, but instead through a "Scheduled Task" as an Application that
runs at logon. There are several options for doing this, an example
would be to run "$TOMCAT_HOME\bin\tomcat5.exe". When setting up the
scheduled task in Windows Vista consider choosing the check-box for
"Run with highest privileges" from the general tab, as this removes
the need to always provide administrator privileges and may resolve
other issues as well.
What I did was to NOT run tomcat7 as a Windows service, but instead just directly execute C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin\Tomcat7.exe and everything worked perfectly. I can simply just put this as a scheduled task so it can still start automatically (or perhaps just put it on startup).

Related

Unable to see networked drive on Windows 10 PC using Java Open Dialog in IDE but see it outside of IDE

Why am I unable to see networked drive on Windows 10 PC with Java Open Dialog. I have noticed a problem when running my Java application from IDE, the Open Dialog does not show my NAS (NetGear ReadyDuo mounted on Z:drive). Yet when I run the application outside of the IDE on the same machine using the same JVM it is okay.
In both cases I'm using Java 1.8.0_72 25.72-b15 64bit on Windows 10 10.0 amd64. I'm sure I didn't used to have this issue but don't know when it started occurring. Its not such a big issue for me if it doesn't show in the IDE because of the IDE, but I'm concerned the IDE may be irrelevant and that potential customers are also seeing this behaviour.
Screenshots below show what I see in the two circumstances
I have encountered this behaviour in other softwares, where the cause was, that the drive was not mapped persistent.
What i did to solve it:
Map your Network Drive with the Windows Explorer GUI and mark "always connect".
or in cmd.exe (please try above 1st!):
net use z: \nas\media /user:usr pass /persistent:yes
Kind regards.
Its not possible for me to comment, so I have to ask here.
Did you tried to run your IDE with Administrator Rights? Maybe some minor 'problems' with UAC (User Account Control).
Solved issue, it seems if you mount a network drive using Windows Explorer, but then run the IDE with administrator privileges then you do not have permission to access the drive because now seen as separate user admin (even though I only have a single user) that wasn't given permission.
The way round is write create batch file to mount the network drive
i.e
net use z: \\nas\media /persistent:yes
and then right click on the batch file and select Run as Administrator
Don't know if there is an easier way.

Java Robot class not working from Jenkins

I am automating a scenario(selenium) where i need to enter credentials in Authentication Pop up, which is generated by the APP. I am using java Robot class to perform this function, it runs fine when i run it from my local machine which is a Windows Platform, but it doesn't seem to work when i trigger the build from jenkins. It hangs at a point where you need to enter the Credentials in Authentication Pop up. I think This is because the jenkins slave is an Unix Platform and this has something to do with the cross platform issue. As i am not sure if Unix Supports the Robot class.
Can somebody suggest me a workaround for this problem ?
Thanks in advance!!
The problem might be that you are testing on a headless server? Make sure your are not using firefox or chrome driver. Try to use the HtmlUnitWebDriver driver instead.

Controlling The firefox launching port

I am a user of selenium webdriver and I am currently running parallel tests in my automation.I have come to understand that firefox launches from port 7054 when first launching via webdriver.I am running 10 tests at a time and I was wondering if there was some way I could control the port on which firefox browser would be launched example if I wish to launch it from port 7056 when i know another is launching from 7054. Thanks in adavnce
It seems that in theory you could do it with .setPreference(PORT_PREFERENCE, portNumber) on the FirefoxDriver, but in reality you can't change the port due to this bug that causes the default port to always override the port preference.
Unless they fixed it in the past 2 months it seems like you're out of luck; although if you are in a bind, you can grab the Selenium source and apply the fix detailed in that bug report on your own as a temporary workaround.
However, if you are running your tests from different processes, you should be able to specify -Dwebdriver.firefox.port=1234 on the command line to change the port for that particular instance of your program. I have not tried it, but the documentation shows that property.

Windows 7 - JAVA - starting or stopping apache 2 (httpd) service

I would like to know how to stop, start, and restarting the Apache (2.0.64) service installed under Windows 7 in my program JAVA (executed in the same machine).
Initially, I developed my apps in Linux environment and I had no problem to do that. Now, I'm migrating in Windows 7, and I can't do it. I have an error message like : "(OS 5)Access denied. : failed to open Apache2 service".
At the beginning, I thought that error is due to the fact that my account system doesn't have enough rights to do so. I tried to change proprietary of folder c:\Program Files(x86)\Apache2, and in Services (open session as my account). It still no working and I get the same message every time.
I need absolutely to control Apache2 process.
If anyone have any ideas that could help me?
Thank you.
One more strange stuff of Windows ....
I figured out why my apps in JAVA didn't work in Windows 7 environment. It juste because since Windows Vista, MS tries to hide the "popup flooding" stuff with something called "UAC - User Account Control".
And in the default configuration, whatever you do; change proprietary of files or services, you still execute them in "limited user" so you don't have trace, you don't know why your programs don't work properly, and you can't even debug it ...
So, if you want to execute an exec stuff in Windows that was installed as "Administrator" role from you apps (Java in my case) , you must play with levels that provide UAC and restart your computer to take effect of that modification.
For me, i set i to the lowess level and it work. I remarked that when i do "Windows"+R, i have a message like "This task's going to be executed as admnistrator privileges"... OK
In short, when you develop with Windows you must debug Windows first, then your apps
....
Welcome to Windows and long life Linux !

How to capture a screenshot when not actually logged into the machine during running Selenium tests with Jenkins on Windows?

We have a CI environment with Jenkins running a test suite of Selenium Tests in a Windows (XP and/or Windows 7) VM. If I am not physically logged into the VM running these tests via RDP, all I see are black (blank) PNGs. I've tried all of the 'capture' methods available (both Base 64 encoded and file based) for multiple Selenium RC 2ish releases (e.g 2.0b2, 2.0rc3, 2.0.0, 2.1.0) and I get the same results for everything I've tried. Is anyone else running Selenium in a Windows CI deployment and able to capture screens? Or better stated, can anyone shed light on how I can capture screens in Windows, using the Selenium API without having to be physically on the box"?
If you are not logged onto the box, or you either closed or minimized the RDP connection, there is no desktop, and screen captures will be blank.
What you need to do is use a VNC server/viewer, so that the machine/vm in question has a visible desktop session.
We are also doing something very similar. We have a windows VM setup which is running Hudson and Selenium Grid.
When our test cases fail we capture a screenshot of the browser so we get more detail of why a test case failed.
We are using the #captureEntirePageScreenshotToString method
We're doing it, and it works for us. We're using JetBrains' TeamCity instead of Jenkins, running on Windows Server 2003. We run the Selenium RC server as a Windows service, using the Java Service Launcher.

Categories

Resources