Problems running Protractor on a Windows Jenkins Slave Node - jenkins

I'm getting an issue while trying to run Protractor on IE11 on a Windows Jenkins Slave Node.
When I connect by remote desktop, I'm able to run Protractor with no issues. However, when I try to run Protractor from Jenkins I run into this issue:
[launcher] Error: UnknownError: JavaScript error (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 396 milliseconds
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: host: 'Win7', ip: '142.133.132.199', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, pageLoadStrategy=normal, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:12492/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=true, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: a43ccc90-f9f7-4465-98c3-dfb88751a5a9
at new bot.Error (C:\Jenkins\workspace\sandbox\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108:18)
at Object.bot.response.checkResponse (C:\Jenkins\workspace\sandbox\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\response.js:109:9)
at C:\Jenkins\workspace\sandbox\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:379:20
at Array.forEach (native)
at goog.async.run.processWorkQueue (C:\Jenkins\workspace\sandbox\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:130:15)
at process._tickCallback (node.js:356:9)
[launcher] Process exited with error code 100
This is weird, because I can run the same tests using any other browsers. Here are some things I tried:
Made sure that Jenkins is using the same account as the one I'm logging in.
Followed the steps on this blog: http://elgalu.github.io/2014/run-protractor-against-internet-explorer-vm/
Changed the protected settings, zoom level and registry key as per this website: https://code.google.com/p/selenium/wiki/InternetExplorerDriver
Tried using the x86 version of the IEDriverServer
Is there anything that I am missing?

I found out that reading documentation is a good thing :) https://code.google.com/p/selenium/wiki/InternetExplorerDriver
Read the configuring section
For IE 11 only, you will need to set a registry entry on the target
computer so that the driver can maintain a connection to the instance
of Internet Explorer it creates. For 32-bit Windows installations, the
key you must examine in the registry editor is
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet
Explorer\Main\FeatureControl\FEATURE_BFCACHE. For 64-bit Windows
installations, the key is
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet
Explorer\Main\FeatureControl\FEATURE_BFCACHE. Please note that the
FEATURE_BFCACHE subkey may or may not be present, and should be
created if it is not present. Important: Inside this key, create a
DWORD value named iexplore.exe with the value of 0.
Worked for me...

I too had problems with Protractor tests under Jenkins, all worked well when I run the test in console, but not in Jenkins.
Turned out, that IEDriverServer does not work, when Jenkins is running as a service (as is the default with jenkins window installer). For IE tests Jenkins MUST NOT RUN AS A SERVICE, instead Jenkins service must be closed and Jenkins started with
java -jar jenkins.war
(in jenkins directory)
(see https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver)

Make sure the versions of your node modules, specifically selenium, are the same on both the local machine and the remote machine.

Related

How to emulate screen on Windows VM in GCP for Electron app screenshare test?

Setup:
test framework around latest WebdriverIO v.7
Jenkins on GCP: master - Ubuntu, slave - Windows Server 2022 VM.
connection between Jenkins master and slave is done with GCP jenkins plugin, so Windows slave is being created for test and then dies.
app under test: Electron v14.2.1 based app.
Test - "User can start screenshare"
User start a call.
User select an available screen and start a screenshare.
Problem:
Electron library can not detect available screen for capturing and sreensharing, because there is no RDP connection opened in test session.
In test logs no sources (screen) found:
2022-08-01 07:40:20:409 -00:00 | info | main-api-handler: - open-screen-picker-window - Properties: {
"cmd": "open-screen-picker-window",
"id": 1,
"sources": []
}
Questions:
How can the screen be emulated?
Where the RDP should be established? Should it?
Are there other way than RDP to provide the screen for the Electron app?
The problem was solved by my colleague:
"So the root cause of this issue is that the SSH server which Jenkins uses to configure the node runs as a service, and that means it has problems interacting with desktop apps. Unfortunately, Windows' own SSH server only runs as a service. More explanations here: Starting GUI programs via OpenSSH on Windows?
To resolve this, I installed a separate SSH server (OpenSSH from MSYS2). The machine image is configured to autologin on boot, and sshd is started on logon as the currently logged in user. This gives it access to the desktop, and screenshare tests now seem to work better"

SEVERE: https://jenkins.domainname.com/tcpSlaveAgentListener/ appears to be publishing an invalid X-Instance-Identity

We're trying to connect a previously connected agent to a Jenkins server.
We get the following error:
SEVERE: https://jenkins.domainname.com/tcpSlaveAgentListener/ appears to be publishing an invalid X-Instance-Identity.
java.io.IOException: https://jenkins.domainname.com/tcpSlaveAgentListener/ appears to be publishing an invalid X-Instance-Identity.
at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(JnlpAgentEndpointResolver.java:287)
at hudson.remoting.Engine.innerRun(Engine.java:694)
at hudson.remoting.Engine.run(Engine.java:519)
The command to run the agent is:
java -jar agent.jar -jnlpUrl http://${private_ip}:8080/computer/mac/slave-agent.jnlp -secret ${secret} -workDir "/var/jenkins-sign"
We're running on a MacOS.
All TCP ports are open internally between the mac and the ${private_ip}. I have telnet working.
As said, this agent was recently connected to the server, but the agent had a restart. We also upgraded the Jenkins server to latest available version.
I updated the agent.jar file.
I think it's related to contacting ${private_ip} while the X-Instance-Identit says "jenkins.dommainame.com", but I am not sure how to resolve it.
I only saw that there were recently changes in this area, but not a lot of helpful information other than that.
Does anyone have an idea?
In case anyone else runs into the issue, in my case it was because I was passing the entire URL, i.e.
http://someurl/jenkins/computer/test/slave-agent.jnlp
and what it really wanted was
http://someurl/jenkins/
Unfortunately, I think it's related to Jenkins upgrade that caused this, and I'm not sure there's a better solution than what I found.
Putting here my solution, but if anyone knows something better, I'd be happy to hear about it :)
Download the agent.jar
Download the slave-agent.jnlp and modify it:
Change all occurrences of https://jenkins.mydomain.com to http://[private_ip]:[port].
Start the process: java -jar agent.jar -jnlpUrl "file:/path/to/dir/slave-agent.jnlp" -workDir "/path/to/dir"
Do not add the secret to this command.
If you're using Jenkins agent as a service, remove the -secret argument from the file.
Set global environment variable jenkins.agent.inboundUrl to your private adderess (with http/https) + port + suffix (if set).
This value will be used as url in JNLP file. This enables using a private address for inbound tcp agents, separate from Jenkins root URL.
see: https://issues.jenkins.io/browse/JENKINS-63222

Cannot start Jenkins service in Windows after updates

I have Jenkins running on Windows as a service. Normally, it starts when machine starts.
After a Windows recommended update this afternoon, and a machine restart, my Jenkins just stopped working.
I start the service but it stops and shows the following warning:
"The Jenkins service on Local Computer started and then stopped. Some
services stop automatically if they are not in use by other services or
programs."
There is no "jenkins.err.log" file and if I start Jenkins with "java jenkins.war" It works fine.
Any tip whats going on? How to fix this? Please help.
Thank you very much.
I had the same problem. It appeared that the java runtime enviromment had been updated. In the jenkins installation folder there is as jenkins.wrapper.log. This contains logging from the jenkins.exe service wrapper. In my case it tried to start java from c:\Program Files\Java\jre1.8.0_144\bin.
This folder did not exist, instead, java was installed in c:\Program Files\Java\jre1.8.0_161\bin.
In the jenkins installation folder there is also a jenkins.xml. This contains the reference to the java installation in the tag. Change it to your current java installation and it will start again.
I also had this problem after each java update. But there is a version-independent absolute path, that can be used to start the java run-time: C:\ProgramData\Oracle\Java\javapath\java.exe.
I changed jenkins-slave.xml to use this path:
<executable>C:\ProgramData\Oracle\Java\javapath\java.exe</executable>
if your java path is correct, disable RunawayProcessKiller in jenkins.xml
extension enabled="**false**" className="winsw.Plugins.RunawayProcessKiller.RunawayProcessKillerExtension"
If the java.exe path is setup correctly in the jenkins.xml/jenkins-slave.xml file and the problem persists, then try to delete the jenkins_agent.pid file and restart the service.
In my case this happened after I installed some updates on my machine. After some research (jenkins.err.log) it turned out that some other application grabbed the port 8080 that was used by Jenkins up to this point.
I managed to identify the app (with TcpView) and disabled it.
Problem solved.
In my case, I installed JDK 17.0.2, but Jenkins requires version JDK 8 to 11.
Check error log under C:\Program Files\Jenkins\jenkins.err for exect error.
My issue was installation of an (unwanted) service that also listens on port 8080. That service failed to start on installation because Jenkins was running at the time, but after a reboot the rogue service started more quickly and nabbed the port. The fix was to disable the unwanted service.
from jenkins.err.log:
java.net.BindException: Address already in use: bind
Caused: java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:8080
Your first stop should be the Windows Event Viewer logs to get a better idea of the underlying error. In my case the error read:
Service cannot be started. System.ComponentModel.Win32Exception (0x80004005): Access is denied
at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited)
at System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean throwIfExited)
at System.Diagnostics.Process.OpenProcessHandle(Int32 access)
at System.Diagnostics.Process.get_Handle()
at winsw.Plugins.RunawayProcessKiller.RunawayProcessKillerExtension.OnWrapperStarted()
at winsw.Extensions.WinSWExtensionManager.FireOnWrapperStarted()
at winsw.WrapperService.OnStart(String[] args)
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
You can examine your Jenkins configuration by looking at jenkins.xml. In my case this included configuration for a RunawayProcessExtension which terminates previous instances of Jenkins before starting the new instance. The <pidfile> entry stores the location of a text file with the PID of the last known instance of Jenkins.
In my case, this <pidfile> was pointing to a PID that was no longer used by a running Jenkins process. Instead, that slot had been taken over by a system process (csrss.exe), causing the RunawayProcessExtension to throw an exception with an "access denied" message when trying to terminate it. Jenkins itself was not starting because it was expecting the RunawayProcessExtension to terminate first.
The solution was to delete the <pidfile> and then restart the service.
It is happing as Jenkins is not able to find java(jdk) path. check jdk path in jenkins.xml file
Resolved this issues
java -version
where java
check jdk/bin -- copy this jdk path
Goto jenkin.xml file and change java path
To resolve this problem follow bellow steps -
Open window task manager(use CTRL + ALT + Delete button)
Navigate to service on the task manager
Click 'Services..' button on task manager
Services window gets opened > Search the Jenkins service and re-start/Start the Jenkins service
Refer Image - Jenkins Service
Now try accessing the Jenkins, problem re-solved
Jenkins service might be stoped.Find the jenkins service in window services and click start.I tried it many times.It worked

Run android emulator on remote machine

I am running appium test and during the test I am trying to activate emulator from remote machine...
My test code is starting appium server on the remote machine and then creates android driver.
In the remote machine I have emulator and appium installed without running the server.
The remote machine IP is : 192.168.14.23 port 4723
In the running machine I have also appium installed.
I am using appium version 1.4.13
Here is the log:
Going to execute start appium server: cmd /c
C://appium//Appium//node.exe
C://appium//Appium//node_modules\appium\bin\appium.js --address
192.168.14.23 --port 4723
[33mwarn[39m: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please
upgrade!
[31merror[39m: Couldn't start Appium REST http interface listener. Requested address is not available.
2015-11-19 14:26:03,586 INFO [main] (Drivers.java:329) - Trying to set ANDROID driver
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote
server or browser start-up failure.
Build info: version: '2.42.2', revision: '6a6995d31c7c56c340d6f45a76976d43506cd6cc', time: '2014-06-03
10:52:47'
System info: host: 'QTVR-AII015', ip: '192.168.23.43', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version:
'1.7.0_79'
Driver info: driver.version: AndroidDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:593)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:109)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:39)
at com.ui.service.drivers.Drivers$Appium.createAndroidDriver(Drivers.java:362)
at com.ui.service.drivers.Drivers$Appium.setDriver(Drivers.java:338)
at com.ui.service.drivers.Drivers.setDriver(Drivers.java:52)
at appium.messaging.basic_concurrent.VisitorThread.initAppiumDriver(VisitorThread.java:67)
at appium.messaging.basic_concurrent.VisitorThread.init(VisitorThread.java:57)
at appium.messaging.basic_concurrent.VisitorThread.
Disable the firewall of both the machines and retry..
You can execute test while hosting appium server in remote machine..
This may also occur if you use virtual network..
is your remote machine is VM??

How to run webdriver test cases on remote staging server(ubuntu) using jenkins?

I pushed the code on github
I have configured Jenkins on
staging.website.com:8xxx , its a Ubuntu machine
I am able to access this ubuntu machine via putty.exe from my windows7 machine
I am able to fetch the code on github via Jenkins means I am able to run the build via Jenkins but it fails as Problem: I am not able to launch the browser.
I tried
DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setCapability("platform", Platform.LINUX);
capability.setCapability("binary", "usr/bin/firefox");
driver= new FirefoxDriver();
driver.get("mytestproject.com");
but it gives error( though I am using latest selenium jar 2.35.0, tried maven clean and restart of server) :
Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows: Error: no display specified Error: no display specified Build info: version: '2.35.0', revision: '8df0c6bedf70ff9f22c647788f9fe9c8d22210e2', time: '2013-08-17 12:46:41' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.5.0-21-generic', java.version: '1.7.0_25' Driver info: driver.version: FirefoxDriver
org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:251)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:195)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:190)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:99)
I have checked using sudo lsof -i :7055that nothing is using this port (via putty on remote ubuntu machine)
But after reading many forums I couldnt solve it. So I tried to use phantomjs but it also gave error :
I tried :
dCaps = new DesiredCapabilities();
dCaps.setJavascriptEnabled(true);
dCaps.setCapability("takesScreenshot", false);
driver = new PhantomJSDriver(dCaps);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get(Prod);
It gave red line below driver = new PhantomJSDriver(dCaps); . Actually I dont know how to use Phantom.js in Maven project.
What I want to achieve : I want to run test case on this remote ubuntu staging server, nomatter headless (ghostdriver) or firefox.
I think it might be failing from Jenkins because it is running in a new terminal window with no display defined. It appears as though the Firefox process doesn't allow this.
"Error: no display specified"
This might help:
How can I specify a display?
Why you not let it to use default Firefox binary? Jenkins need only Firefox that is installed for All Users. If i remember correctly firefox is default in any Ubuntu.
Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055;

Resources