-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
99 lines (89 loc) · 5.64 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import streamlit as st
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
import pandas as pd
from tests import *
TEST_DESCRIPTIONS = {
"Check web page title": ["Verify that a web page title matches an expected value.", first_test],
"Check presence of Get Started button": ["Verify that a web element is present on a web page.", second_test],
"Check login without credentials": ["Verify that no login is possible with empty credentials.", third_test],
"Check login with correct credentials": ["Verify that login is possible with correct credentials.", fourth_test],
"Check login without username": ["Verify that login is not possible with empty username.", fifth_test],
"Check login without password": ["Verify that login is not possible with empty password.", sixth_test],
"Check functionality of Get Started button": ["Verify that website goes to login/register page after clicking on 'Get Started' button.", seventh_test],
"Check developers page": ["Verify that Developers page is accessible.", eighth_test],
"Check projects page": ["Verify that Projects page is accessible.", ninth_test],
"Check recommendations page": ["Verify that Recommendations page is accessible only for logged in users.", tenth_test],
"Check inbox page": ["Verify that Inbox page is accessible only for logged in users.", eleventh_test],
"Check sign up page": ["Verify that Sign Up page is accessible.", twelth_test],
"Check sign up with empty credentials": ["Verify that Sign Up is not possible with empty credentials.", thirteenth_test],
"Check sign up with empty name": ["Verify that Sign Up is not possible with empty name.", fourteenth_test],
"Check sign up with empty username": ["Verify that Sign Up is not possible with empty username.", fifteenth_test],
"Check sign up with empty email": ["Verify that Sign Up is not possible with empty email.", sixteenth_test],
"Check sign up with empty password": ["Verify that Sign Up is not possible with empty password.", seventeenth_test],
"Check sign up with all credentials": ["Verify that Sign Up is possible with all credentials.", eighteenth_test],
"Check edit profile button": ["Verify that Edit Profile button is accessible only for logged in users.", nineteenth_test],
"Check editing name": ["Verify that name can be edited.", twenteeth_test],
}
@st.cache_resource
def get_driver():
return webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
st.title("DevFinder Automated Testing App")
selected_test = st.sidebar.selectbox("Select a Test", list(TEST_DESCRIPTIONS.keys()))
all_tests = st.sidebar.button("Run All Tests")
st.write(f"**Test Description:** {TEST_DESCRIPTIONS[selected_test][0]}")
if st.button("Run Test"):
st.write(f"Running test: {TEST_DESCRIPTIONS[selected_test][0]}")
options = Options()
options.add_argument('--disable-gpu')
options.add_argument('--headless')
driver = webdriver.Chrome()
output = TEST_DESCRIPTIONS[selected_test][1](driver)
if output:
st.success("Test passed!")
else:
st.error("Test failed!")
driver.quit()
if all_tests:
st.write("Running all tests...")
options = Options()
options.add_argument('--disable-gpu')
options.add_argument('--headless')
driver = webdriver.Chrome()
outputs = []
for test in TEST_DESCRIPTIONS:
st.info(f"Running test: {TEST_DESCRIPTIONS[test][0]}")
output = TEST_DESCRIPTIONS[test][1](driver)
outputs.append(output)
driver.quit()
st.header("Test Plan")
st.write("The following table shows the test plan for the DevFinder web application.")
test_results = {
"Check web page title": "Test Passed" if outputs[0] else "Test Failed",
"Check presence of Get Started button": "Test Passed" if outputs[1] else "Test Failed",
"Check login without credentials": "Test Passed" if outputs[2] else "Test Failed",
"Check login with correct credentials": "Test Passed" if outputs[3] else "Test Failed",
"Check login without username": "Test Passed" if outputs[4] else "Test Failed",
"Check login without password": "Test Passed" if outputs[5] else "Test Failed",
"Check functionality of Get Started button": "Test Passed" if outputs[6] else "Test Failed",
"Check developers page": "Test Passed" if outputs[7] else "Test Failed",
"Check projects page": "Test Passed" if outputs[8] else "Test Failed",
"Check recommendations page": "Test Passed" if outputs[9] else "Test Failed",
"Check inbox page": "Test Passed" if outputs[10] else "Test Failed",
"Check sign up page": "Test Passed" if outputs[11] else "Test Failed",
"Check sign up with empty credentials": "Test Passed" if outputs[12] else "Test Failed",
"Check sign up with empty name": "Test Passed" if outputs[13] else "Test Failed",
"Check sign up with empty username": "Test Passed" if outputs[14] else "Test Failed",
"Check sign up with empty email": "Test Passed" if outputs[15] else "Test Failed",
"Check sign up with empty password": "Test Passed" if outputs[16] else "Test Failed",
"Check sign up with all credentials": "Test Passed" if outputs[17] else "Test Failed",
"Check edit profile button": "Test Passed" if outputs[18] else "Test Failed",
"Check editing name": "Test Passed" if outputs[19] else "Test Failed",
}
df = pd.DataFrame()
df["Test Name"] = list(test_results.keys())
df["Test Description"] = [TEST_DESCRIPTIONS[test][0] for test in TEST_DESCRIPTIONS]
df["Test Result"] = list(test_results.values())
st.dataframe(df, width=2000)