[No X11 DISPLAY variable was set] UI Test Automation at EC2 with Ubuntu 22.04 LTS

0

Hello!

I'm trying to run UI automation tests (Java 17, Selenium etc.) at EC2 instance with Ubuntu 22.04 LTS.

By default this image is headless so I've installed tool for GUI representation:

https://shrihariharidas73.medium.com/how-to-setup-gui-desktop-with-ubuntu-on-aws-ec2-ea713d836a58

sudo apt install xrdp -y
sudo systemctl enable xrdp
sudo add-apt-repository ppa:gnome3-team/gnome3
sudo apt-get install gnome-shell ubuntu-gnome-desktop 

After this manipulation I'm able to connect via RDP to current EC2 instance, UI works fine.

Also I've installed xvfb to avoid possible issues. But still I'm getting error:

java.awt.HeadlessException: 
No X11 DISPLAY variable was set,
but this program performed an operation which requires it.

My question: is it possible to run UI tests at EC2 instance with Ubuntu OS? (not in headless, but in UI mode)

Is it a configuration issue or should I use some other image for this purpose?

Thanks!

asked 20 days ago151 views
2 Answers
0

Dear Mike L Thanks for your assistance!

I'm trying to execute provided commands, but I've faced another issue:

ubuntu@ip-172-31-36-14:~$ sudo apt-get install -y ubuntu-desktop
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 2496 (unattended-upgr)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
ubuntu@ip-172-31-36-14:~$ sudo apt-get install -y ubuntu-desktop
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 2496 (unattended-upgr)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
ubuntu@ip-172-31-36-14:~$ sudo apt-get install  -y gdm3
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 2496 (unattended-upgr)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
ubuntu@ip-172-31-36-14:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.4 LTS
Release:        22.04
Codename:       jammy
  1. Is it something that could be fixed?
  2. And is it possible to use Ubuntu AMI with already installed GUI?
answered 19 days ago
    1. You do not need to install GNOME again. The commands are for a new instance
    2. As per last paragraph in my post, you can launch Ubuntu instance with GUI and NICE DCV using CloudFormation. Follow the steps in the linked post, and select console for sessionType.
    3. You can also go to AWS Marketplace(https://aws.amazon.com/marketplace) to get Ubuntu with GUI. Note that there may be additional software charges.
0

XRDP uses its own X server. You need to login to graphical desktop, and run your automation job from there.

You can install GNOME directly without PPA

sudo apt-get install -y ubuntu-desktop
sudo apt-get install  -y gdm3

Do ensure that your Ubuntu is using graphical run-level

sudo systemctl set-default graphical.target
sudo systemctl isolate graphical.target

To connect to your graphical console on your Ubuntu 22.04, you may need to install VNC or maybe enable Remote Desktop sharing

Or you can install NICE DCV with console session for graphical console access. Refer to Installing the NICE DCV Server on Linux for installation instructions.

Instead of installing graphical desktop and NICE DCV server manually, you can also use this Ubuntu CloudFormation template to launch a new instance. Do select console for sessionType. Screenshot below for illustration. Refer to this link for guided instructions.

Enter image description here

AWS
EXPERT
Mike_L
answered 20 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions