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/
-
This is a simple demo application with login page using streamlit, where i want to do load testing.
-
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
else:
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")
else:
st.error("Invalid username or password. Please try again")
if __name__ == "__main__":
main()
- 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)
driver.get('http://localhost:8502/')
driver.maximize_window()
time.sleep(3)
username_field = driver.find_element(By.XPATH,"//input[@aria-label='Username']")
username_field.send_keys('username')
time.sleep(2)
password_field = driver.find_element(By.XPATH,"//input[@aria-label='Password']")
password_field.send_keys('password')
time.sleep(2)
login_button = driver.find_element(By.XPATH,"//p[normalize-space()='Login']")
login_button.click()
time.sleep(2)
driver.quit()
- 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
- Now i wrote the 3rd script named ex: load_test.yaml and the script looks like this
---
execution:
- executor: selenium
scenario: login_scenario
concurrency: 2
ramp-up: 3s
hold-for: 20m
iterations: 5
scenarios:
login_scenario:
script: ./2_pyt_sel_web.py
properties:
webdriver:
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.
-
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.
-
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.