Constantly active window. Winium. Automated GUI tests - java

A constantly active window. I neeed an emulation of that a real person is looking at the screen.
I have to write automated tests for windows application, so I choose a Winium(https://github.com/2gis/Winium).
But I have a 1 problem. All this tests running on virtual machine and i also start them from jenkins, but they will work only if I connect by RDP to virtual machine and maximize window.
If I just connect by RDP, but minimize window, all tests gonna fail.
So can you help me, and say, are exists some kind of programs which emulate "human presence"? Also glade to hear about you expreience in Automated GUI and what of programm you're using.

As a successful workaround, I've written a Visual Basic script that simulates continuous key presses on NumLock. This keeps my Remote Desktop session alive, even with the window minimized. My Winium scripts run fine within a grid (Hub-Node) setup (both hub and node are VMs) and the simulated keypresses don't interfere with testing.

Related

Couple of Cucumber scripts failed due to a higher screen resolution - JAVA

I have my regression suite setup in jenkins and it executes on windows server 2012 r2. Recently I changed screen resolution to 1920,1080 by using below code
driver.manage().window().setSize(new Dimension(1920,1080));
All the other test scripts get passed except two ( let's say script1 and script2 ) in headless mode on the server. But those two scrips get passed in my local machine in both headless and browser mode.
And also when I execute those two scripts in browser mode on the server with the same screen resolution, again they get passed.
When I change the screen resolution to
driver.manage().window().setSize(new Dimension(1366,768)); It get passed on the server in headless mode.
Since I'm using the same configurations for the rest of the scripts. I couldn't think of an exact thing happening here. When I build the Jenkins job, it executes all the other scripts and when it comes to script1 execution hangs. Jenkins build also hangs and doesn't come to the end. Looking for a solution for this.
I'm using webdrivermanager and chrome version of the server is 96
By default, VM screen size is very small (--window-size=1040,784), so while automating things, decrease your screen size to this value and automate, otherwise, we will face this issue.
To increase VM screen size, you need to increase virtual memory of your R2 server. that will end up with high cost.
solution:
Automate with smaller screen size.
or Run it in headless mode
I did troubleshoot and here are my findings,
It was a loop which was never ending if element not found
inside the loop, it searches for an element which was appeared only in a small screen resolutions (arrow button to navigate through some tabs. when the screen resolution is higher, all the tabs appear in the page and no arrow button visible)
So that's the reason those scripts work in small screen resolution and failed in higher resolutions
I changed the loop accordingly and now I can execute all the scripts with higher resolution on the server with headless mode

Pick a file using native Windows picker on a Jenkins master (headless) node

I have Selenium test which picks a file via native Windows file picker window. This is achieved by using Java Robot class. This works fine when the test runs with a normal session (i.e. with a GUI). However when running test on a Jenkins master node tests are performed from other user and there is no active desktop session in this case, and files cannot be picked.
Is there a way to deal with this without setting slave node with a GUI?
There are lot of articles which suggest all the same ways to deal with file picking, but none mention about dealing with Windows native file picker when running a test from master node (with different user).
Robot can't be used in a headless environment. It's a known limitation. So you have to use active desktop mode. The same is valid for tools like SikuliX / AutoIT.

Netbeans RCP application not working outside the IDE when built as OS independent zip

I am building a statistical analysis application on Netbeans RCP for solving tests faster and with less effort https://github.com/PaulMaxAvalosAguilar/Statistikos-Klubas.
The thing is very simple:
1.-There's a module called TrabajosViewer which uses the nodes API to display workspaces where you can organize your samples with some meaningful name, first you create a workspace and then you add some data to it.
2.- You open editor top component which calculates some descriptive satistics stuff for all the sample you entered
3.- All stuff you need for a test is done! Samples are stored in an embedded H2 database(datos module) and results are calculated each time you click on a TrabajosNode.
However when I was testing the app I had to add the following sample:
https://1drv.ms/t/s!AkZmosJJMvdIu3c_IiVkD6JAVVgk (3344 elements); as the app had multithreading capabilities everything was fine, except that after building a release as OS independent zip the app froze from the swing Top Component which was very rare as that wasn't happening on inside Netbeans IDE. I think it has something to see with the build script since I built a Gradle version an everything worked fine https://github.com/PaulMaxAvalosAguilar/Statistikos-Klubas2
If you have an app - any Java app really, not just NetBeans RCP - and it freezes then what you want to do is obtain a thread dump. The thread dump will almost always give the clue as to why there's a freeze.
Java has 5 or 6 different ways to obtain a thread dump for a running application (just google it). Out of these methods, the one preferred is the so-called Ctrl-Break method because it is the one which gives most information. The downside of the method is that you need to have started your application from a console window. But if you can consistently replicate the freeze, then I don't think that's a problem for you. Here's what you would do if you are on Windows:
Start cmd.exe
From the command window, start your application, e.g. bin\sillyapp64.exe.
Wait for the freeze to happen on your application
Now press Ctrl-Break in the command window. This will give you a thread dump printed into your command window.
Upload the thread dump as part of your question. (or host it somewhere if it is too big)
Instructions for Linux/MacOSX are similar albeit in step 4 you would instead send your process a QUIT signal using the kill command.

Error: When i minimize Internet Explorer which is running the automated WebDriver Code

I have written the Selenium webdriver java code to automate the test and its working fine. But I have lot of data input to test my web and it takes time. So when i minimize the IE to do some other task while it is running the automation, it is throwing error:
org.openqa.selenium.ElementNotVisibleException: Element is not displayed
Selenium WebDriver is trying to simulate "real" users interaction with the webpage. If a person can't click on a button not currently displayed, neither can Selenium.
ElementNotVisibleException occurs when the element you want to interact with is not displayed. When you minimize the browser some of the elements are no longer visible, even though they where in maximized window.
You can add scroll using moveToElement() from Actions class every time you want to perform any action (I don't recommend it, you increase significantly the chance for errors), or find another hardware solution, like plugging in another screen, run the test on another computer etc.
According to my experience, the Internet Explorer WebDriver is very oversensitive when it comes to disturbances from a real user while running test cases. It's better to not touch anything at all. ;-)
Try Chrome! This is much more robust and also faster.
Selenium script runs as a simulator. You cannot do another work when script is running. Chrome is fast but while running script in chrome you can not do other task like any other browser. If you minimize window, you will get exception "ElementNotVisible".

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