When macbook is locked, selenium safari tests initiated by Jenkins on the mac wont run - selenium

I have made sure that the mac does not sleep by adjusting the settings in the system preferences. Jenkins will start the test on a schedule, the browser comes up but the test fails because the page is blank.
The same test works with no problem if the mac is unlocked or the screen save is not up.
I cannot leave the mac unlocked because the test runs at night and its a security issue.
Has anyone encountered this issue? And have a solution. Please share.
Attaching some logs. This image will give an idea of what I am describing.

You can try to run tests on locked computer when:
you set your display never turn off, when you lock your computer
you made sure, that computer never goes in hibernate or sleeping mode
If it will not work you can use two more possibilities:
run your tests on headless browser. Here is a pretty good explanation how to do it.
run your tests on a remote screen via VNC or RDP
EDIT:
You can try not lock the screen, but instead start the screensaver, and require the screensaver to immediately require a password.

Related

Chromium on startup behavior is different that launching it manually

I have a Jetson Nano that runs LXDE. After booting it should automatically start Chromium in kiosk mode and launch a web page. The web page is very simple, just adding and removing some rectangles or images based on web socket messages.
Since sometimes the DOM gets updated, sometimes not, I thought my web page has some bug. But this behavior is only on the Jetson Nano. Furthermore, when I launch the Chromium manually with the exact same parameters, I have no problem at all, everything runs as expected.
I also observed that the Chromium (the autostarted one) instantly updates the DOM correctly when I press Alt+Tab (since it is the only application, no application is really switched). So apparently nothing has happened since the last web socket message, I just press Alt+Tab, and the web page instantly is displaying the correct things. Additionally it is very difficult to bring up the developer console, pressing ctrl+shift+i for several minutes, when you are lucky it fires up the developer console. Once it is there, the web page is again working normally.
I have no idea what I can do about it. I just want to launch the Chrome so it behavior is like when I start it normally.
Currently, the autostart is done inside ~/.config/lxsession/LXDE/autostart with the line #/home/agx/dev/autostart/chromium.sh, this file is:
#!/bin/bash
sleep 60
chromium-browser --new-window --password-store=basic -kiosk --js-flags='--jitless' http://192.168.1.50/index.html
I tried to delay the start hoping it would help but it changed nothing. Same for jitless. I can execute exact this command manually in the console, chromium fires up and behaves normally.
How can I trace this one down?

Manually setting QUARANTINE_THRESHOLD and DISCONNECT_THRESHOLD in testcafe does not work

I changed the QUARANTINE_THRESHOLD and DISCONNECT_THRESHOLD in test_run_controller.ts file to 1 million each and built successfully however, my test still fails after around 1000-10000 restarts with the error :
ERROR The Chrome 89.0.4389.90 / Linux 0.0 browser disconnected. This problem may appear when a browser hangs or is closed, or due to network issues.
Is there something else that may be forcing testcafe to quit? or is the issue in browser perhaps?
Thank you
According to the error, your browser hangs for some reason. The problem could be in the way you organize your tests. It's likely that you have some code that leads to memory leaks, and after 1000-10000 restarts, your machine does not have enough RAM to run the browser.
Please clarify why you need to restart your tests 1000-10000 times.
I changed the QUARANTINE_THRESHOLD and DISCONNECT_THRESHOLD in
test_run_controller.ts file
We are working on the quarantine mode configuration, so you will have the capability to change quarantine options out of the box.

Raspberry Pi browser won't start on startup

I want my browser to start on startup. At the moment it works quite randomly. On some boots the browser flashes quickly and is running in the background. When this happens, I can't start a new browser session before I kill the existing one.
How can I prevent this from happening? I'm currently doing this with a shell script, but I've also tried the autostart method and both give me same results.

Can the karma-script-launcher also close something after the tests finish?

I'm using the karma-script-launcher to open a virtual machine/browser/url but when the tests are complete I don't know how to close everything.
If I leave the browser open in the virtual machine it eventually stops trying to reconnect - no error message just fails to reconnect. I'm not sure if this is a bug or not. I can't see why you wouldn't want the browser indefinitely trying to reconnect? What ever the reason it leaves me needing to close and re-open the browser each time I run the tests. But if I'm using the script launcher I don't see how this is possible.
Thanks for any help
not quite sure if this covers your answer but I stumbled over your question while looking for a solution to a similar issue, so let me explain - in case someone else encounters this issue.
Was running karma unit tests on codeship ci environment for a nodejs app.
Tests were successful, however the test would keep watching and wouldn't shut down, thus setting the tests to 'passed' - instead it would idle and after a while timeout, setting the tests to 'failed'.
Setting the option singleRun to true within the karma config helped.
Hope this helps anyone who's having the same issue.
Sorry if not topical enough :S

Getting black images with selenium.captureScreenshot

I'm executing selenium tests with testng, that are started on a remote system with Selenium RC via hudson (with ssh connection). The remote system is windows xp with MKS Toolkit installed, hence ssh. Tests are NOT executed as a windows service.
I've tried using both captureScreenshot and captureEntirePageScreenshot methods. The first one always produces a black image. The second one creates the correct screen shot but it only works on Firefox and our tests usually pass on Firefox and fail in other browsers, so it is crucial to capture screen shots for the other browsers (mainly IE and Safari). The tests are ran in parallel, with many browser windows open at the same time. I'm not certain if this is what's causing the problem. Any thoughts will be appreciated.
Unfortunately screenshots in Selenium have been problematic from the start in browsers that are not Firefox. This is something that we Selenium Developers have been working on for a while to correct.
The latest work has been updating Snapsie to work in IE. There is a blog post at http://blog.codecentric.de/en/2010/02/remote-screenshots-mit-selenium-und-dem-robot-framework/ that explains what has happened.
I have noticed that if the screen isn't active, i.e. the screensaver has kicked in, it can produce black screenshots.
Edit:
I just had a thought. You can always run Castro to video record your tests and then watch it play back. This is something SauceLabs use to run Selenium in the cloud.
Write a method for this and call that whereever you need to take the screenshot. Use the java.awt package which has been used in selenium. For example, check this site
After setting Windows Auto-Logon, and launching process not as Windows Service, I found how to solve the Remote Desktop with Black Screenshots problem of IEDriverServer.exe, by creating a batch file that disconnects RDP, instead of closing the RDP session with the regular X button:
%windir%\system32\tscon.exe %SESSIONNAME% /dest:console
See more details here:
https://stackoverflow.com/a/24529629/658497
(Although, I would prefer there was a way to run it as the default action, when terminating RDP session with X Windows button).