Jenkins started selenium, but can't access chrome localStorage - google-chrome

I use Jenkins to start a selenium standalone serve with chrome driver. It starts OK. But when I use it with intern tests, the chrome tests don't start. I got this in the log:
org.openqa.selenium.WebDriverException:
unknown error: Runtime.evaluate threw exception:
DOMException: Failed to read the 'localStorage' property from 'Window':
Access is denied for this document.
If I start selenium locally, everything works fine. Note Jenkins slave service uses the same user as the local login.
Ther batch script I used to start Jenkins is this:
start cmd /c java -jar C:\Jenkins\workspace\app\util\selenium-server-standalone-2.44.0.jar -Dwebdriver.chrome.driver=C:\Jenkins\workspace\app\util\chromedriver.exe 2^> seleniumLog.txt
Why does it not work when I start selenium from Jenkins?

If you use Jenkins as a service standalone server can't create real window.
You can use workaround. Create Node and run from usual user (auto startup). Run your Job on that node
P.S.
For normal screenshot (not black screen) you can put session to Console "tscon RDP-tcp#0 /dest:console" (set screen resolution by QRes tool).

Related

Disable log4net errors on command prompt while using rotractor/Selenium web driver/Chrome browser

Is there a way to completely disable log4net errors appearing on npm console while running test cases . I am using Protractor and Selenium Web driver. I would like to know if this is possible through Protractor's config file Capabilities.

Chrome nativeMessaging example fails on Windows

I downloaded the official Chrome nativeMessaging example to test it out.
To do this, I installed the app from chrome://extensions, by choosing Load Unpacked. No problems so far.
I then installed the host. I'm using Windows 7, so I ran install_host.bat, which claimed that "The operation completed successfully." However, when I go to chrome://apps/ and click the Connect button, I get this error:
Failed to connect: Native host has exited.
Is there some reason this would happen? Restarting Chrome did not fix the issue, nor did uninstalling and then reinstalling the host program.
(I noticed that native-messaging-example-host.bat requires Python 2, so I modified it to run Python 2 explicitly. If I run native-messaging-example-host.bat from the command line, it pops up a little example program of its own with a GUI and seems to work correctly.)
Turns out I was using a non-standard character in the path leading to the host executable. This wouldn't be a problem for any other program, but Chrome's native messaging API doesn't like it, I guess.
By the way, the documentation on setting up this example is near-nonexistent, but this stack overflow link has some useful info: Chrome Extension NativeMessaging 'connectNative' undefined

Puppeteer authentication does not work in headless mode but yes in non headless mode

I'm facing up a strange problem in Puppeteer with authentication.
I've written a script to take some screenshot of a website which required authentication.
In my local computer (windows), when running in command line as node.exe my_script.js; it's working fine (in headless moden which is the default mode).
I've written an upper Java program to manipulate it (dynamically set the path, the node modules path, run the process "nodex.exe my_script.js" every 30minutes, manage timeout of the process,...). It's still working directly running from Eclipse, in headless mode.
Then... I've built/packaged a JAR and running it in a cmd window: java -jar my_jar.jar... and then the script can't authentitcated on the website in headless mode (the answser page just write a message like "you need to be authenticated", which is managed by the http server).
To check what happen, I've just add an option in my nodejs script (so I do not modify my java upper program code) to run chrome in non headless mode; with option headless : false. And... it's working!
I let the option to run in non headless mode, and I create a Windows service to run my jar via a bat file, with the help of nssm... Just to test. I'm really happy to see that all is running fine without seeing any chrome GUI (maybe Windows disable GUI for service, don't know how).
Have I maybe missed something? Or is there a bug in Puppeteer or Chrome to manage authentication in headless mode?
Regards
Alex

Jenkins doesn't launch the application under test on chromebrowser

I ran into an issue with Jenkins which I've never seen before and I thought I'll get some advice. Jenkins wouldn’t launch the AUT on the chrome browser for running selenium tests.
Steps that I followed:
A Jenkins Master and Slave are setup on the same machine. Not as a windows service, but I launch them manually via command prompt
I setup a project on the Slave node with 2 build steps. One for the MSBuild (I dowloaded the plugin) to build the solution and the second step for executing the windows batch command that will start the tests
I also have a TFS plugin to fetch the server version of the solution to build on Jenkins
So when I build the job on Jenkins Slave,
The solution gets built successfully without any errors
Then for the next build step, Jenkins executes the windows batch command and loads the .dll file. Says “starting execution..”
Chromedriver launches. It opens up the chrome browser
But the chrome browser wouldn’t launch the AUT. It just tries to load it and stays intact indefinitely until my Jenkins job times out
With all this happening, my CPU utilization is at 100%. The browser that runs the Jenkins UI on the local host and Java.exe*32 consumes it to the fullest
I ran the exact same MSTest.exe command (that I entered in the build step) in command prompt when Jenkins is not running and it launches the AUT successfully and tests ran
I ran the exact same MSTest.exe command (that I entered in the build step) in command prompt when Jenkins is running. It again spikes the CPU to 100% and AUT never launches
Any thoughts?
I was also running into this issue and solved it as follows.
Basically the jenkins slave has to be started from the startup through a batch job.
Here is the step by step process.
Node URL : http://host:port/computer/nodeName/
Go to the node "Node URL"
Click on "Mark this node temporarily offline"
Go the the machine where slave is running.
Open command prompt in admin mode.
cd to the location where jenkins is installed
Execute jenkins-slave uninstall
Go to services (type services in run) and stop the jenkins slave running
Restart the machine.
cd C:\Users\myUserName\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Create a new batch job (name say LaunchJenkinsSlave.bat) with following content
>
java -jar C:/Jenkins/slave.jar -jnlpUrl http://host:port/computer/nodeName/slave-agent.jnlp -secret yourSecret
netsh advfirewall firewall set rule group="remote desktop" new enable=Yes
<<
fyi : You can refer jenkins-slave.xml in your Jenkins install location for yourSecret, nodeName, host ect if you forgot.
Restart your machine.
Observation : Jenkins slave will be started automatically
12. Go to the "Node URL"
and bring the node back online.
Hope this helps.

Chrome crashing when launched by Karma executed from MSBuild

My build server service is executing the following command from an msbuild file:
Exec Command="karma start $(LandscapeExplorerProjectFolder)karma.conf.js -- log-level debug
This then launches a Karma instance running on Node.js
Karma is configured to launch Chrome to run my Jasmine tests. When I execute the above command manually by logging on to the server and typing into the command prompt, the tests run as I would expect.
However when Karma is started by my build service, Chrome is initially launched but then crashes.
From the output of the console when running a build I get the following:
WARN [launcher]: [39mChrome have not captured in 60000 ms, killing.
DEBUG [launcher]: [39mProcess Chrome exited with code 0
When looking in the Chrome log I see:
[6888:2988:1105/162913:ERROR:child_process_launcher.cc(444)] Failed to launch child process
[6888:2988:1105/162913:WARNING:sad_tab_view.cc(105)] Tab Killed: http://localhost:9876/
The exact same console command works fine when executed manually, but there is something about the way the build service is executing things that is causing Chrome to crash. Does anyone have any ideas about this?
I've seen this issue before.
I was not able to resolve it, but was able to workaround it.
This seems to be related to running Jenkins as SYSTEM account on Windows - if this is the case, try changing the service to run as a service account.
I worked around this with PSexec - you can download the tool at:
https://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
And then use it in the job to exec Karma:
C:\Path\to\pexec.exe -s -i -accepteula karma start $(LandscapeExplorerProjectFolder)karma.conf.js -- log-level debug
Again this seems to be related to spawning child processes with SYSTEM.