Running Hub and Nodes remotely on Windows without a user logged into the machine - selenium

Selenium GRID2 is setup with a hub and three nodes (VMs Windows). All the config files are set and I start the services with a couple batch files executed on each machine. Once everything is started up it works great. When the remotely connected user who executed the batch files actually logs out of the machine the tests fail to connect to the browsers anymore.
I could leave the user account logged on after starting everything and just stay logged on. However, I would much rather find a way to get the services to startup and stay active without any user logged on the systems. Is there a way to force all the services to stay active after all users logout of the machine. Also need the full browser to function as there are screenshots as well. Could someone point me in the right direction or tell me how to get that to work or if it's possible?

Setup a scheduled task via Task Scheduler to execute the batch files to start the node on each machine. You can set a trigger to execute the batch file on system startup, or at a specific time.
Also, when creating the task, select the option "Run whether user is logged on or not"
I also add a task to restart the node machines (every night) to keep it clean of stale browser windows.Since the node batch files runs at startup, you do not need to login to the hub/node machine to start it manually.

Related

Start a bat file remotely which never returns anything (jmeter-server.bat)

So we are doing distributed testing of our web-app using JMeter. For that you need to have the jmeter-server.bat file running in background as it acts as sort of a listener. The problem arises when one of the slave machine out of 4 restarts due to the load and the test is effectively stuck right there as the master machine expects some output from the 4th machine. Currently the automation is done via ansible-playbooks which are called in Jenkins. There are more or less 15 tests that are downstream to one another. So even if one test is stuck, the time is wasted until someone check on the machines.
Things I've tried so far:
I've tried using the Windows Task Scheduler and kept the jmeter-server.bat to run without any user loggin in, but it starts the bat file in background which in-turn spawns all the child processes in the background as well i.e. starts Selenium Chrome in headless mode.
I've tried adding the jmeter-server.bat in startup and configuring the system to AutoLogon without any password to trigger a session which will call the startup file. But unfortunately the idea was scrapped by IT for being insecure.
Tried using the ansible playbook by using the win_command but it again gets stuck as the batch file never returns anything.
Created a service as well for the bat file, but again the child processes started in background.
The problem arises when one of the slave machine out of 4 restarts due to the load
Instead of trying to work around the issue I would rather recommend finding the root cause and fixing it.
Make sure to follow JMeter Best Practices
Configure Java to take heap dump on failure
Inspect Windows PerfMon and operating system/application logs
Check presence of .hprof files in the "bin" folder of your JMeter installation and see what do they say
In general using Selenium for conducting the load is not recommended, I would rather suggest using JMeter's HTTP Request samplers for that, given you properly configure JMeter to behave like a real browser from the system under test perspective there won't be any difference whether the load comes from HTTP Request samplers or from the real browser.
The same states documentation on the WebDriver Sampler
Note: It is NOT the intention of this project to replace the HTTP Samplers included in JMeter. Rather it is meant to compliment them by measuring the end user load time.

Selenium automation - running from a common folder

I am trying to setup a shared folder on vm and from that folder setting up automation. Is there a way that all the people who have access to that folder can see automation running? See chrome instance running autmation?
Usually, CI like Jenkins is used to run automation on VM and collect results.
But as for your question - to be able to view automation tests running on the browser on VM user should be logged in to that VM by Remote Desktop Connection.
Having a shared folder on VM can't help you to see tests running on VM because it doesn't mean users who have an access to it have a user account on that VM.
I would recommend creating one testing user account on that VM and share it with the team.
Run is performed on the agent, there is no way to see real time run on the agent without being logged in. You can record the run, save video to your shared folder, so users within access to that shared folder will have an access to saved videos.

Selenium / Protractor not able to run browser tests (E2E) if the user running it is not interactively logged-in

We have a Continuous Integration agent that runs with the identity of a non-logged-in user (non interactive) - i.e. the agent does work with sufficient Windows user credentials, but no user is "physically" logged-in to Windows and the agent run as a scheduled task with sufficient privileges.
The problem is that under these circumstances Selenium is not able to open a browser to actually run browser tests.
What could be the solution?
This guide just briefly mentions how to configure the Windows user to be able to run a browser with a non-logged-in user (using control userpasswords2) but that advice doesn't work.
To clarify, this problem is not specific to the Bamboo CI agent (referred to in the above link). It's common to all scenarios where Selenium running on behalf of a non-logged-in user would try to run a browser.
You need to have an interactive session to interact with. I believe this question on SuperUser Run interactive task even if user is not logged on Windows as well as the instructions from Atlassian you linked are the correct answer.
Once the user is set to auto-login, you need to reboot the system to cause that auto-login to occur. The recommendation in the linked question of forcing a lock after the login is a good one for security, but still provides an interactive session for the CI/Selenium to work against and without running under System with limitless privileges.
If this does not fix your problem after following all the directions and rebooting, and you have verified that the user is in-fact logged in at the time you run the CI/Selenium (typically you can check this with Remote Desktop and looking at that logged in user for the console session in Task Manager > Users tab), then there is most likely a different problem.

running selenium as a RC in IE, as a scheduled task

I'm trying to automate a task using Selenium-RC where the user doesn't have to be logged in. Here's the ideal scenario:
Running as a scheduled task and the user is not logged in.
Selenium will start at a scheduled task, open IE and go about the script.
I'm not sure this is possible, but I need to simulate user interactions with IE without the user being logged in. what would be the best way to do this?
IDEA:
would I able to put Selenium on a virtual machine, have the virtual machine run as a scheduled task on a physical machine; so when the user is logged out the virtual machine can still be started, and selenium will run on the virtual machine.
If you are using ant build, you could create a batch file to invoke the build. Now you could schedule the execution of batch.
I suppose you could same while using TestNG framework with java. So you create a batch file for executing test using testng.xml and then have it scheduled.

can we execute QTP script on remote machine by keeping session minimized

I have couple of machines on which I wish to schedule exceutions. I need to access these machines remotely for exceution. Whenever I start exceution from these machines and minimize the session my script fails. So just curious to know whether QTP scripts can be executed while keeping sessions minimized. If yes what changes needs to be made in script. Thanks.
When you minimize this window, the operating system switches the remote session to a GUI-less mode and does not display windows and controls. As a result, the tests are unable to interact with the tested application’s GUI as the GUI doesn’t actually exist in this case.
You need to change Registry keys on your computer (that is, the computer from which you connect to a remote QTP workstation). Here is a step-by-step description:
Close Remote Desktop sessions opened on your computer.
Click Start and select Run. In the Run dialog box, type regedit and press Enter. Registry Editor starts
Locate any of the following Registry keys:
HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\
(if you want to change the RDC settings for your user account)
-- or --
HKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server Client\
(if you want to change the RDC settings for all accounts)
Create a new DWORD value in this key named RemoteDesktop_SuppressWhenMinimized. Specify 2 as the value data.
That’s all. Now minimizing the Remote Desktop Connection window on your computer will not affect the remote computer’s GUI and the GUI will still be available to your automated GUI tests.
This was taken from: http://blog.smartbear.com/post/10-10-11/testcomplete-tip-running-tests-in-minimized-remote-desktop-windows/
The problem you're facing is that if you minimize your display the remove machine knows that it doesn't have a display and ignores any questions about control locations and requests to move the mouse. In some cases QTP runs tests using device replay which means that the test will fail.
To work around this you need to have the remote machine think that it still has someone attached to it. One way is (obviously) to not minimize or close the remote desktop session. Another way is to use a remote access program that doesn't inform the remote machine when it's minimized a free example of such program is VNC, if I remember correctly you can even close the VNC session (not just minimize it) and the test will still run successfully.