Load/ Stress testing on Streamlit web app

Hi all,
I have to load/stress testing for a web app we built using Streamlit.
1.I am running the app locally. at http://localhost:8502/

  1. This is a simple demo application with login page using streamlit, where i want to do load testing.

  2. Once after entering the credentials, click on login button.

This is the behavior of the app.

The streamlit code is shown below

import streamlit as st

def login(username, password):
    if username == 'username' and password == 'password':
        return True
        return False
def main():
    st.title("Login Page")
    username = st.text_input("Username")
    password = st.text_input("Password", type="password")
    if st.button("Login"):
        if login(username, password):
            st.success("Login Successful")
            st.error("Invalid username or password. Please try again")

if __name__ == "__main__":
  1. Now I need to automate the above behavior using python selenium framework.
    This also works correctly. The code for python selenium is attached below.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
import time

chrome_driver_path = 'C:\\Drivers\\chromedriver.exe'
service = Service(chrome_driver_path)

driver = webdriver.Chrome(service=service)


username_field = driver.find_element(By.XPATH,"//input[@aria-label='Username']")

password_field = driver.find_element(By.XPATH,"//input[@aria-label='Password']")

login_button = driver.find_element(By.XPATH,"//p[normalize-space()='Login']")

  1. Now i have to do load/stress testing on the above tool using using Taurus. Here in taurus, the script is written in yaml file. For this i refered this link

Taurus API Testing | Complete Guide | Blazemeter by Perforce

  1. Now i wrote the 3rd script named ex: load_test.yaml and the script looks like this
- executor: selenium
  scenario: login_scenario
  concurrency: 2
  ramp-up: 3s
  hold-for: 20m
  iterations: 5
    script: ./2_pyt_sel_web.py
        type: chrome
        path: "C:\\Drivers\\chromedriver.exe"

Here 2_pyt_sel_web.py is the name of the python selenium script.
For this Taurus, we need to install library called bzt i.e pip install bzt

and run using the command

bzt yaml_file.yml

here in my case it is bzt 3_load_test.yml

Now when i run this yaml file, it gives an error even though i used the same format and indentation. and the error screenshot attached below.

  1. Here in the yaml script we can set the concurrency as number of virtual users using the tool ie concurrency:10 means 10 users are using the tool and taurus will check the load.

  2. The actual taurus status should show like this

    But in my case it is showing like empty

And exits saying No tests found as shown in error screen shot

If any one has come across this issue, then please comment on this.
Thank you.

1 Like

Hi @keshav_dk

For app testing, Streamlit has a built-in approach as outlined in the App testing Docs page:

Hope this helps!

Hi @dataprofessor ,
Thank you very much for the reply.
I checked the AppTest and looks useful for functionality testing.

But in our case , we need to mainly do load/stress testing on our web based tool by adding parameter concurrency(i.e concurrency: 10 which means 10 users are using the tool at a time, so that we can check how the server takes the load and also we can increase the concurrency)

I referred this below shared article for Streamlit application load testing

1 Like