selenium web driver on windows 7 parallels vm - browser hidden - allow service to interact with desktop? - windows

I am using a script on my mac host to launch a selenium node on a local parallels VM.
Something like
"prlctl exec Win7-VM-Name-Here 'C:\path_here\start_node.bat'"
The node starts up nicely and registers itself with the hub. I can run tests fine against this node.
However, when the tests are running, the browser is not visible on the VM, which means that screenshots are useless.
I think it has something to do with allowing a service to interact with the desktop, but I can't figure out which one, or how to proceed.
Any help?
Thank you.

Unfortunately, this is a common problem with selenium (or any other browser automation software) on Windows. If selenium is running in the background as a service, the browser will not appear when the tests are being run and taking screenshots will just result in a black picture. If you want to be able to watch the tests being run and grab screenshots, the general consensus is to start your script manually from the command line and leave it running.

Related

How to have multiple GUI displays from multiple bashes of a Linux Docker Container using Vcxsrv in Windows host?

I currently have an Ubuntu docker container to run GUI applications called Gazebo and ROS. I am using Vcxsrv to run the GUIs on my windows host os and am able to display a GUI. However the problem is that I can only display one GUI from one bash of my running docker container at a time as I am able run my first GUI program, Gazebo, in the first docker container bash. But after I run a new bash with "docker exec -it bash" and then run another GUI program, like one called Rviz, I get the error here:
root#:/# rviz
qt.qpa.xcb: could not connect to display [ip here].1:0.0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.
Aborted
Therefore, I tried to run my "config.xlaunch" file again and then the rviz command but the same error occurred. After, I looked at the small vcxsrv icons in the right of my taskbar and one of them said "DESKTOP-Q:0.0 - 7 clients" which corresponded to my first GUI application running. However, the second icon showed "DESKTOP-Q:1.0 - 0 clients" which should run my second GUI application. Therefore I was wondering what I would need to do for multiple GUI applications to run in multiple docker bashes of the same running container? Thank you.
Turns out I had to change around the DISPLAY environment variable in the Docker container from virtual ethernet to wireless adapter and visa versa. And I did this after I launched one of the GUI programs. After you are able to launch the second GUI program you do not have to switch environment variables anymore. This solution does not seem the best so therefore please feel free to post a better solution.

Automate tests on virtual machine without graphical session

Context :
I execute automated GUI tests on virtual machines (there are few of them) on running on windows and using UFT/Ranorex, executions are piloted by Jenkins.
Problem:
VM must have an active graphic session, otherwise, UFT won't run GUI tests (unable to launch browser) and Ranorex will run but poorly and without screenshots. i mean that in my tests, the VM is configured not to "sleep" or to have any screen saver, vm is connected with jenkins properly.
The behavior is : i launch via Jenkins the test, one the build done inthe vm, automation tools start running but then finds difficulties to open browser.
I would like to know if there is any workaround to run those tests without being needed to physically open VMware or Remote desktop Connection.
Notice that the VM is running all the time and the session is always open (we are using a server to host the VM).
So the problem is: how to simulate in windows active graphical session. I guess it's like simulating that there is actually a screen connected even though there isn't...
Any suggestions will be welcomed.
Had to go through this many times and you can find a lot of resources related to your issue in the Ranorex Forum. (My username there is Martin for reference).
But to go through the points you need to do quickly:
1) Have an RDP machine to connect to that is used to run your tests
2) You need to disable screen saver for that machine (I had to do it from registry)
3) Then disable the "On Resume, display logon screen" option under Personalize settings for the screen saver
4) And finally create a .bat script with the following content "%windir%\System32\tscon.exe RDP-Tcp#0 /dest:console"
So basically when you have everything set up (required only once) you will run the .bat script. This will close the RDP window BUT the session will be left open with the screen enabled.
Just connect the RDP with Jenkins and you have full functionality that you need to run your tests.
Regards
Martin
In the Tools ⇨ Options menu, select General ⇨ Run Sessions there you will find an option to Enable continued testing on locked/disconnected remote computers.
If this fails, see my other answer.
I had the same problem when I try to run an automate tests on virtual machine and I find this solution to generated a graphical session although you are not connected to the virtual machine. You need to created a task to opend a session on the virtual machine when you disconected or terminated the session , this created a graphical session but will not function when you are connected and you have the screen minimize. Here is the link for the solution and the explanation
http://blogs.microsoft.co.il/arnona/2016/01/03/keeping-an-active-desktop-session/

Black screen when taking screenshot with Internet Explorer driver on Windows build server

I am running several automated browser tests with selenium on our build server. There is no problems taking screenshots while running Chrome or Firefox driver, but when running Internet Explorer driver I just get a black screen.
Virtual Machine
Selenium version: 2.53.0
IEDriver: 2.53.0
OS:
Windows Server 2012
Browser:
Internet Explorer 11
I have gone through all the required configuration in the documentation https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
I have also tried the third option here:
https://lostechies.com/keithdahlby/2011/08/13/allowing-a-windows-service-to-interact-with-desktop-without-localsystem/
I have also enabled service interaction globally:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms683502(v=vs.85).aspx
When I remotely access the build server, I can trigger running the tests manually. This works fine. So there must be a problem with our CI(TeamCity) setup interacting with the build server.
I am currently stuck and could need some help ?
This is the default behavior of Windows. since Internet Explorer is tightly coupled with Windows, it behaves this way but other browsers don't.
In order to have better resource utilization, when running on remote, windows detects that since session is running in remote mode and nobody is watching the screen, it takes away the resources required to show the screen and screen goes black. When you log into the machine, resources to show screen UI are deployed again.
Hence, when running in remote mode, since there is no screen being showed, screenshot comes out to be blank.
There are only workarounds, no solution.
Workaround:
Workaround 1: Use VNC server for your remote session instead of RDP since VNC keeps the remote session alive.
Workaround 2: Add this command to batch file : tscon rdp-tcp#1 /dest:console
It will switch the session to "1" which is active mode.
By default it will be running on "0" mode. It will disconnect your session and now you can run your test case.

Upon executing a selenium test, spin new Windows VM, execute commands, then exit?

I am running a Mac but need to test Web applications in IE. Ideally, I would love to be able to execute a selenium command on my box, and it would spin up a VM (VirtualBox, VMWare, something like that), run the commands in IE, and then exit the VM once I'm done. Is that possible? If not, does anyone else have a better idea of how to run selenium commands in a Windows environment from a box that is not Windows? My commands are in Python 2.7, if that matters. Thanks
Your requirements shall be possible to fulfill.
Selenium can be using "Selenium Server" and your python code using selenium package shall be able talking to it - it uses http protocol for such a remote control.
Selenium server is using Java, and as it is started, it shows url on which it awaits commands.
These urls can be then used in your python code when constructing driver for your browser, there you specify url of remote Selenim server and shall be able continuing as if you would work locally.
Description how to connect is here.
Feel free to comment or reply to me how it went, it sounds very interesting but I do not have any real experience with that so far.

Starting webDriver endpoint in current users's desktop from linux through powershell

I have a test cluster that contains a linux machine, an iMac and a windows 7 PC.
The linux machine hosts junit tests that I wrote and the other two machine serve as endpoints for browser automation tests using webDriver.
The script that executes the junit tests loops through different browsers and executes the junit tests against each browser using selenium webDriver. So far, the browsers include iphone, ipad, safari (mac), firefox (mac), chrome (mac), IE10 (win7), firefox (win7), chrome (win7).
While developing this test cluster, I encountered random crashes of webDriver on each of the two endpoints and found it necessary to write a kill/restart of the webDriver jar file. Now, this was a relatively simple matter on the iMac, but on the Windows 7 PC this is proving to be extremely difficult.
The linux machine has a script that checks to see that the webDriver endpoint is available by checking http://windows.Host:4444/wd/hub/status and if it isn't, it shells into powershell on the Windows 7 PC (I have freesshd setup to point to powershell instead of cmd.exe) and runs these commands:
Stop-Process -name java
Start-Process -FilePath C:\webDriver.bat
webDriver.bat contains:
java -jar C:\selenium-server.standalone-2.33.0.jar
Here is the problem I am having:
when powershell restarts webDriver using the above comands, the wedDriver endpoint is reachable but not visible. My tests proceed but fail because the browser is not running in the current desktop but instead some virtual one or another users Desktop. When I run webDriver.bat manually, webDriver runs in a cmd.exe window and the tests execute against all win7 browsers fine, providing webDriver doesn't crash.
Here is my question:
How do I make webDriver execute in such a way that my tests proceed and run correctly, rather than in the background/another user's desktop? These tests are part of Build Verification and need to be run on demand, so having someone manually run webDriver.bat is not an option.
I previously tried to have webDriver's jar running as a service and using samba to restart that service as needed, but ran into the same problem. Powershell seemed to be a better alternative with better control and the ability to verify that the jar file is running, but I don't know if I am heading in the wrong direction here.
I don't relish having to learn powershell to accomplish something that was relatively easy on another OS, but understand that this may be my only option. I also know that the commands I'm using do not constitute a good script and welcome suggestions on how to better achieve my goal here.
Thanks.
Sounds like you just need to pass the host option like so:
java -jar selenium-server-standalone-2.37.0.jar -host 0.0.0.0
Powershell might have permission restrictions on binding to all ports that can be overcome by setting the correct policy. See my blog post here for ideas.
You question is pretty long winded...can you shorten it?

Resources