Unable to run test using SSH

Hi

Im trying to run a test suite over SSH ( from MacOS 10.12.6 to an Ubuntu 16.04 machine ) but im getting the below errors:

- [ERROR]  - java.lang.ExceptionInInitializerError
- [END]    - End action : DashboardUtils.Utilities.openWebBrowser
- [ERROR]  - Test Cases/UtilityScripts/SaveFixture FAILED because (of) org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.ExceptionInInitializerError

Im able to run the test suite natively on the Ubuntu machine without issue, its only when i do it remotely. Ideally, once i know i can run remotely, id then look to use Jenkins to fire a shell script ( which contains the Katalon terminal command to run the test suite ).

Im not sure why im getting errors only when ssh’ing in. The first command is to simply open the browser ( see below )

public class Utilities {
  @Keyword
  def openWebBrowser() {
    WebUI.openBrowser('')
    WebUI.maximizeWindow()
  }
  ...
}

I also have tried with the vanilla WebUI API ( so to rule out any custom Keyword issues ):

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.checkpoint.CheckpointFactory as CheckpointFactory
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as MobileBuiltInKeywords
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testcase.TestCaseFactory as TestCaseFactory
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testdata.TestDataFactory as TestDataFactory
import com.kms.katalon.core.testobject.ObjectRepository as ObjectRepository
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSBuiltInKeywords
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUiBuiltInKeywords
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
WebUI.openBrowser('')
WebUI.navigateToUrl('https://www.google.com/?gws_rd=ssl')
WebUI.setText(findTestObject('TestingPlayground/googleHomePage/Page_Google/input_q'), 'news')
WebUI.click(findTestObject('TestingPlayground/googleHomePage/Page_Google/input_lsb'))
WebUI.closeBrowser()

But get a different set of errors:

- [START]  - Start action : openBrowser
- [END]    - End action : openBrowser
- [ERROR]  - Test Cases/TestingPlayground/OpenGoogleHomePage FAILED because (of) java.awt.HeadlessException: 
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
- [END]    - End Test Case : Test Cases/TestingPlayground/OpenGoogleHomePage

But im able to run this simple example natively on the Ubuntu 16.04 machine without issue, which seems to reinforce this is an SSH based issue.

The command im using to run the shell script once i have ssh’d in ( the shell script also runs natively on the Ubuntu 16.04 machine ):

cd $HOME/Downloads/Katalon_Studio_Linux_64-5.4.1
./katalon --args -email="myemail" -password="mypassword" -noSplash -consoleLog -runMode=console -projectPath="$HOME/repository/katalon-testing/test-project.prj" -statusDelay=5 -retry=3 -retryFailedTestCases=true -testSuitePath="Test Suites/GoogleHomePage" -browserType="Chrome"

Im not sure if im missing any command line argument or other setting.

Any advice would be appreciated.

Jason,
I think it is an environment issue. I found similar information at https://stackoverflow.com/questions/662421/no-x11-display-variable-what-does-it-mean.
Could you double check on the solution they provided?

Hi Trong

Thanks for sharing that link, in a nutshell running

export DISPLAY=:0.0

On the Ubuntu machine solved the issue. I hadn’t initially considered that the remote machine wasn’t running a UI, so this would clearly not be able to open the browser to begin with.

I have added the DISPLAY variable to ~/.bashrc so it loads every time i ssh in (so no need to re-add every time).

Thanks Trong, that post you linked to was just what i was looking for :slight_smile: