Streamsync: Better Streamlit alternative? Answer it by automation test!

Get started with Streamsynch and playwrite for automation testing

Nicola Landro
2 min readAug 1, 2023

Streamsync is a zero-frontend-code UI library for python so it is an alternative to Gradio and Streamlit. This library is open source like gradio but get the freedom of Streamlit to create interfaces.

Sample counter app with Streamsync

I just see explanation about streamsyc here so I show how it can be easily tested with playwrite.

This article is made after my study it in this repo.

Pro & Con

The Streamsynch have a freedom and html/css/js more like interface that is better than Gradio and Streamlit for freedom and customization.

That is also an advanteges because you can customize more but you must know more.

Another advantages is the edit tool with UI in witch you can put elements into the UI and automatically generate the JSON file that describe the UI. It also suggest how to use funcion from pyton.

Make simple app

Use this commands to create testapp

pip install streamsync
streamsync create testapp

Now you can run the app with:

streamsync run testapp

(And you can edit with `streamsync edit testapp`)

Make test

Install playwrite

pip install pytest-playwright
playwright install
playwright install-deps

Create first test file test/test_testapp.py

from playwright.sync_api import Page, expect


def test_streamsyc_app(page: Page):
page.goto("http://localhost:3005")

expect(page.get_by_text("26")).to_be_visible()

button_plus = page.get_by_role("button", name="Increment")
button_plus.click()

expect(page.get_by_text("27")).to_be_visible()

button_less = page.get_by_role("button", name="Decrement")
button_less.click()

expect(page.get_by_text("26")).to_be_visible()

With running server we can run test with

pytest test

Test automation pipeline

CI/CD gitlab

For made the test automation pipeline on gitlab you can use the following .gitlab-ci.yml

test:
image: ubuntu:22.04
script:
- apt update
- apt install -y python3 python3-pip
- pip install -r requirements.txt
- pip install pytest-playwright
- playwright install
- playwright install-deps
- streamsync run testapp &
- pytest test
when: manual

Conclusions

Streamsync is a bit hard than streamlit and gradio but it is more ready for production and get help by frontend developers to made together and simply a good UI and UX experience.

It is all open source! So contribute!

--

--

Nicola Landro

Linux user and Open Source fun. Deep learning PhD. , Full stack web developer, Mobile developer, cloud engineer and Musitian.