安排测试以验证部署的 streamlit 应用程序是否正常工作

Schedule tests to verify if a deployed streamlit app is working or not

我创建了一个 streamlit 应用程序,部署了它并与其他几个人共享了它。为了确保应用程序 运行 流畅,我每 4 小时手动登录一次应用程序,输入少量输入值并检查应用程序中的所有选项卡是否都已填充?有没有一种方法可以通过输入输入值并自动验证我的应用程序具有的所有选项卡来检查应用程序是否正常工作。

我在 automated testing of streamlit apps using seleniumbase. My post (code copied below) focuses on pixel-perfect display between code runs, but it could easily be extended to testing inputs using other features of seleniumbase 上写了一篇博客 post:

from seleniumbase import BaseCase
import cv2
import time


class ComponentsTest(BaseCase):
    def test_basic(self):

        # open the app and take a screenshot
        self.open("http://localhost:8501")

        time.sleep(10)  # give leaflet time to load from web
        self.save_screenshot("current-screenshot.png")

        # test screenshots look exactly the same
        original = cv2.imread(
            "visual_baseline/test_package.test_basic/first_test/screenshot.png"
        )
        duplicate = cv2.imread("current-screenshot.png")

        assert original.shape == duplicate.shape

        difference = cv2.subtract(original, duplicate)
        b, g, r = cv2.split(difference)
        assert cv2.countNonZero(b) == cv2.countNonZero(g) == cv2.countNonZero(r) == 0