Launching a process using pysphere in activatedWindow mode - pysphere

When I launch various processes on VM's on my ESXi server the default opening style of any process is minimize,i.e the window is not activated. Does anyone know how to activate that window using pysphere?

Related

How can I emulate pressing CTRL+ALT+PAUSE in my Linux VM using AutoKey?

Question:
How can I emulate pressing CTRL+ALT+PAUSE in my Linux VM using AutoKey?
I tried a script that has
keyboard.send_keys("<ctrl>+<alt>+<pause>")
in it. But it does not work.
Background:
I'm using Windows 10 and RDP to log into a Fedora Linux. Switching 100 times a day.
The RDP connection runs in Windows all the time.
If the RDP window is not in the background but active, I can press CTRL+ALT+PAUSE to go into the VM (Fullscreen). If I am inside the VM I can press CTRL+ALT+PAUSE to go back to Windows.
So far so good. I want only one button. Preferably PAUSE. Windows part is ready already with following script
Pause::
If !WinExist("RDP Tool Name")
MsgBox No Window found
WinShow, RDP Tool Name
WinActivate, RDP Tool Name
Send ^!{CtrlBreak}
Return
Is the Linux part maybe not possible because the key combination is cached somewhere before my Linux system can even notice it? Any ideas?
I solved it without any other new script. I just had to edit the RDP settings: Keyboard -> Use Windows-Hotkeys -> On this Computer

Setting display resolution for Selenium tests on virtual machine as Jenkins Slave

I'm having trouble running some Selenium tests on a Jenkins Slave. To be specific, the display resolution that is used to run the tests is too small, causing some of the tests to fail.
To check the display resolution, we log the display height and width to the console, using:
driver.manage().window().maximize();
System.out.println("Window height: " + driver.manage().window().getSize().getHeight());
System.out.println("Window width: " + driver.manage().window().getSize().getWidth());
This returns:
Window height: 784
Window width: 1040
which seems like a very strange resolution to me. The desired resolution is 1920 x 1080.
The server that is used as a slave is a virtual machine (Windows Server 2012 R2). The Jenkins Slave is Connected via JNLP agent. The slave has the service running with Log On As "Local System" with the "Allow service to interact with desktop" option enabled.
So far we've tried a number of things like:
Connecting to slave VM using RDP and disconnecting to leave session open with desired display resolution
Using powershell to set the display resolution
Setting the default display resolution in the VM configuration
Setting the window dimensions using Selenium
And more...
All of these didn't resolve the issues. Suggestions are very welcome!
Finally managed to fix these issues after realizing that Jenkins does not necessarily need to run the slaves as a windows service. To start the slave, the JNLP agent can be downloaded from Jenkins and copied to the server. When running the JNLP file, you can select for the option to install the slave agent as a service.
Previously we had this option selected, that's why the slave was running as a service. After stopping and removing the service, we ran the JNLP file again and made sure to not select the option.
The solutions suggested that included disconnecting the remote desktop session and leaving the session open with a large resolution didn't work when running the slave as a service. They do work however when running the slave in the default way.
Make sure that the remote desktop session is not ended after a certain period of time:
Hope this helps someone!
Based on my experience with this you can't solve this problem programmatically. Your tests will run on the resolution which was used last time when you physically accessed this VM's display. For example, if I open VM on my big screen monitor and maximize it, tests will run on that resolution. But if I open it on my laptop screen and close RDP connection, tests will run on that smaller screen size.
I know it sounds strange, but I really couldn't find better solution. :D So now I must be careful to maximize VM display on my bigger screen before I close VM. You will probably dislike this answer, but remember it when you find yourself out of other solutions. ;)
Solution that worked for me is to run Chrome in a 'headless' mode (without GUI). It works with Jenkins Agent running as a service, when GUI is not available.
Here is the code sample of the web driver initialization:
var options = new ChromeOptions();
options.BinaryLocation = #"C:\Program Files\Google\Chrome\Application\chrome.exe";
options.AddArgument("Headless");
options.AddArgument("window-size=1920,1080");
driver = new ChromeDriver(#"<path>\Selenium.WebDriver.ChromeDriver.2.37.0\driver\win32", options);
I've been experienced the same issue. My seleniumn tests run under jenkins slave installed as windows service, using "Local System" account with "Allow service to interact with desktop" option enabled in windows 7. Some test cases were always failed due to incorrect display resolution.
I logged in to the console of the windows VM (EXSI Server + VMware Fusion), changed the resolution to 1400x900, and restart the windwos VM. Everything works well now.

Is it possible to run UFT scripts on virtual machines?

I am writing scripts which will install UFT and do all the configuration setting require to run the UFT scripts. My UFT scripts are browsing some urls etc.
I want to know if I do it in Virutal Machines then is it possible to run the UFT scripts on those servers as they won't have mouse and keyboards attached.
Want to run automatically on machines without logging into the machines.
In case if you are simulating mouse & keyboard actions (like hitting ENTER, Clicking on particular coordinate etc) in your script, It will work fine even if mouse and keyboards are not connected to a computer. Basically you are simulating mouse and keyboard clicks w/o actually using them.I assume you have verified your scripts in your local machine. If it works fine, Then it will also work fine in your VM.(assuming your VM has enough permissions/all the prerequisites installed/configured etc).
It works. I use it every day. You can even use analog recording in the VM with a Remote Connection to the VM with no problems as well.

Java Robot Code does not work when remote desktop window is not active

I'm running some selenium tests on a amazon cloud machine. My web application has a flash area where i'm simulating a keyboard type and click using java robot code (also tried auto it script to simulate user click and type on the flash area) . The code works when i connect to the server using remote desktop and the remote desktop window is active, but when i minimize the remote desktop window, the java robot code does not work?
Robot robot = new Robot();
robot.delay(5000);
robot.mouseMove(400, 400);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(2000);
robot.keyPress(KeyEvent.VK_H);
robot.keyPress(KeyEvent.VK_I);
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyPress(KeyEvent.VK_B);
robot.keyPress(KeyEvent.VK_U);
robot.keyPress(KeyEvent.VK_D);
robot.keyPress(KeyEvent.VK_D);
robot.keyPress(KeyEvent.VK_Y);
Issue is not with the scripts, but with the host machine's GUI settings for remote machine. To fix this, perform the following steps on the computer from which you are connecting to a remote workstation :
Configuration for current user only:
Run the regedit.exe tool.
Find the registry key HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client.
Create a DWORD value with the name RemoteDesktop_SuppressWhenMinimized and set its value to 2.
Now find the registry key HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Terminal Server Client.
Create a DWORD value with the name RemoteDesktop_SuppressWhenMinimized and set its value to 2.
Close the regedit.exe tool.
Configuration for all users:
Run the regedit.exe tool.
Find the registry key HKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server Client.
Create a DWORD value with the name RemoteDesktop_SuppressWhenMinimized and set its value to 2.
Find the registry key HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Terminal Server Client.
Create a DWORD value with the name RemoteDesktop_SuppressWhenMinimized and set its value to 2.
Close the regedit.exe tool.
Now when you minimize the Remote Desktop Connection window on your computer, this will not affect the remote computer’s GUI and the GUI will be available to your interactive tasks.
I installed UltraVNC Server and connected using VNC client. The problem is not observed and the robot works even after disconnecting. Below is the exact steps:
Login to the remote machine using Windows Remote Desktop tool.
Install UltraVNC server as a Windows service.
Log off from the system (you are still within the remote desktop tool).
Now using VNC viewer, connect to the system.
You will be shown the login screen. You can login to the system using vnc viewer now.
Thanks, Daniel,
This resolved the issue we had while running a Synthetic Scenario where we need to use Robot Framework to perform some mouse clicks while the RDP Session is minimized.
Best Regards,
Buddhika.
Germain UX: Custom Insights, Alerts, and Automation platform to improve User Experience

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.