Panel app UI test --headed - connecting to remote server

I am following this how-to to test UI for my Panel app. I have to mention that my code leaves and runs in an Ubuntu machine, and I’m connecting to that server via SSH using my Windows laptop.

All is good as long as I’m running tests headless. But When I run a headed test, I get the following error.

playwright._impl._errors.TargetClosedError: Target page, context or browser has been closed
Looks like you launched a headed browser without having a XServer running. Set either 'headless: true' or use 'xvfb-run <your-playwright-app>' before running Playwright.

Then I installed xvfb and ran the following command which means I just added xvfb-runner to the begining of my command.
xvfb-run pytest myapp/tests/test_frontend.py --headed --slowmo 1000

This way, the tests run, but no browser showing on the display. What am I missing? What setting do I need to provide in order to see the browser? Ultimately, I like to be able to to use codegen to write UserStory tests.
xvfb-run -a playwright codegen --target python my_app_url

But again, when I run this command, it just waits. I get no error, but no browser shows either. While this process is running, from another terminal, I run a ps -aux | grep xvfb command. Not only I can see xvfb-run command,
pts/20 S+ 09:59 0:00 /bin/sh /usr/bin/xvfb-run -a playwright codegen --target python my_app_url
I also see the X server process:
Xvfb :99 -screen 0 1280x1024x24 -nolisten tcp -auth /tmp/xvfb-run.

Then I learned that I need to install and configure Xming on my windows to allow the graphic to show on my pc. I did all of that. No luck yet.

Apparently, I have everything to run this. How can I direct the browser to my laptop screen?
I’ve done a lot of research, but no luck. I hope this community can help me with this.

1 Like

Hi @Marc ,
As I didn’t get any answer for my question, I decided to ping you to ask what your setting was to run this test. I appreciate any tip.

Hi @Mana

I was running locally on a windows laptop.

Your usage of Playwright with Ubuntu, SSH and Windows is advanced and I believe you would have the same challenges using any other web framework. I would recommend searching Playwright resources and asking the question again in the Playwright community forum. I think there would be a higher probability of someone knowing there.

By the way normally users would just be testing with pytest alone. Have you created a custom widget based on javascript that requires you to test with Playwright?

Thanks @Marc for your response and good tips.

No, I haven’t created a custom widget. I’ve been using pytest for component tests. The reason that I needed Playwright codegen is to write user stories/user interaction test. I need to test a series of actions happening one after the other and automate those tests.

I’ll share the progress here if I get it working. :crossed_fingers: