No X11 DISPLAY variable was set, but this program performed an operation which requires it


#1

Hi,
While running the test on redhat linux box then getting below error message and script execution is failing.

Reason:
java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at org.sikuli.api.robot.desktop.AWTDesktop.(AWTDesktop.java:27)
at org.sikuli.api.robot.desktop.DesktopScreen.getSize(DesktopScreen.java:43)
at org.sikuli.api.AbstractScreenRegion.(AbstractScreenRegion.java:19)
at org.sikuli.api.DefaultScreenRegion.(DefaultScreenRegion.java:37)
at org.sikuli.api.DesktopScreenRegion.(DesktopScreenRegion.java:11)
at com.kms.katalon.core.webui.common.ScreenUtil.(ScreenUtil.java:26)

I tried to set DISPLAY (export DISPLAY=:0.0 or export DISPLAY=:0) value also then below error message is coming -
Reason:
java.awt.AWTError: Can’t connect to X11 window server using ‘:0’ as the value of the DISPLAY variable.
at org.sikuli.api.robot.desktop.AWTDesktop.(AWTDesktop.java:26)
at org.sikuli.api.robot.desktop.DesktopScreen.getSize(DesktopScreen.java:43)
at org.sikuli.api.AbstractScreenRegion.(AbstractScreenRegion.java:19)
at org.sikuli.api.DefaultScreenRegion.(DefaultScreenRegion.java:37)
at org.sikuli.api.DesktopScreenRegion.(DesktopScreenRegion.java:11)
at com.kms.katalon.core.webui.common.ScreenUtil.(ScreenUtil.java:26)

Can someone please help?


#2

Are you setting up the execution yourself, or using the Katalon Docker image?


#3

I am simply running command on redhat Linux 7 box on Chrome headless browser. Not using docker.


#4

As far as I know Sikuli requires a desktop to work correctly. One option is to execute the tests with normal Chrome and Xvfb. You can take a look at this script as an example:


#5

Can someone please help on this?


#6

Hi,

are you set your display as
DISPLAY=:1

this is needed that cause X11 programs need to know where to display windows


#7

Yes. I tried but getting below error message -

java.awt.AWTError: Can’t connect to X11 window server using ‘:1’ as the value of the DISPLAY variable.


#8

Could you please try using xvfb-run to create a virtual display (as shown in my previous answer)? For example, xvfb-run -s "-screen 0 1024x768x24" "<your Katalon Studio command>".


#9

hi,

is it your X started and runs ok?


#10

How I can check?
Can you please tell me the command?


#11

HI,

not sure, try e.g. this way
ps -fea | grep x

found from the web

X=$( pidof X )
if [ ${#X} -gt 0 ]
then
        echo "X has already been started"
else
        /usr/bin/startx
fi

#12

Hi, are you using custom image?

I think so katalon isnt enable to use other user non-root

Regards


#13

Hi,

I am running into this issue. Kindly provide steps to resolve this issue.

Thanks and Regards
Vikas