CP_StressTest
This commit is contained in:
parent
5daca15d62
commit
fa9ce0f149
@ -324,6 +324,14 @@ class DomainAssessmentPage(BasePage):
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def is_submit_button_visible(self):
|
||||||
|
"""Check if submit button is visible and enabled"""
|
||||||
|
try:
|
||||||
|
submit_btn = self.find_element(self.SUBMIT_BUTTON)
|
||||||
|
return submit_btn.is_displayed() and submit_btn.is_enabled()
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
def get_all_questions(self):
|
def get_all_questions(self):
|
||||||
"""
|
"""
|
||||||
Get all question IDs on current page
|
Get all question IDs on current page
|
||||||
|
|||||||
@ -454,39 +454,92 @@ def complete_assessment_flow_for_student(
|
|||||||
pass
|
pass
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Check if submit button is enabled
|
# After answering, check if this is the last question (submit enabled)
|
||||||
|
# If submit is enabled, break and submit. Otherwise, click Next.
|
||||||
|
is_last_question = False
|
||||||
try:
|
try:
|
||||||
submit_button = driver.find_element(*domain_assessment_page.SUBMIT_BUTTON)
|
submit_button = driver.find_element(*domain_assessment_page.SUBMIT_BUTTON)
|
||||||
if submit_button.is_enabled() and submit_button.is_displayed():
|
if submit_button.is_enabled() and submit_button.is_displayed():
|
||||||
|
is_last_question = True
|
||||||
steps_completed.append(f"All questions answered ({questions_answered} questions)")
|
steps_completed.append(f"All questions answered ({questions_answered} questions)")
|
||||||
break
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Step 11: Submit assessment
|
if is_last_question:
|
||||||
|
# Last question - break loop to submit
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
# Not last question - click Next to continue
|
||||||
|
if domain_assessment_page.is_next_button_visible():
|
||||||
|
try:
|
||||||
|
domain_assessment_page.click_next()
|
||||||
|
RandomizedWait.wait_for_navigation('next')
|
||||||
|
except Exception as e:
|
||||||
|
print(f"⚠️ Error clicking Next after question {question_id}: {e}")
|
||||||
|
# Try to continue anyway
|
||||||
|
consecutive_failures += 1
|
||||||
|
if consecutive_failures >= max_consecutive_failures:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
# Next button not visible - might be last question or error
|
||||||
|
# Check submit button one more time
|
||||||
|
try:
|
||||||
|
submit_button = driver.find_element(*domain_assessment_page.SUBMIT_BUTTON)
|
||||||
|
if submit_button.is_enabled() and submit_button.is_displayed():
|
||||||
|
is_last_question = True
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
# If still not last question, this is an error
|
||||||
|
consecutive_failures += 1
|
||||||
|
if consecutive_failures >= max_consecutive_failures:
|
||||||
|
break
|
||||||
|
|
||||||
|
# Step 11: Submit assessment (only if submit button is enabled - last question)
|
||||||
if domain_assessment_page.is_submit_button_visible():
|
if domain_assessment_page.is_submit_button_visible():
|
||||||
domain_assessment_page.click_submit()
|
domain_assessment_page.click_submit()
|
||||||
RandomizedWait.wait_for_submission('submit')
|
RandomizedWait.wait_for_submission('submit')
|
||||||
steps_completed.append("Submitted assessment")
|
steps_completed.append("Clicked Submit button")
|
||||||
|
|
||||||
# Step 12: Handle submit confirmation modal
|
# Step 12: Handle submit confirmation modal
|
||||||
if domain_assessment_page.is_submit_modal_present():
|
if domain_assessment_page.is_submit_modal_present():
|
||||||
domain_assessment_page.confirm_submit()
|
domain_assessment_page.confirm_submit()
|
||||||
RandomizedWait.wait_for_submission('confirm')
|
RandomizedWait.wait_for_submission('confirm')
|
||||||
steps_completed.append("Confirmed submission")
|
steps_completed.append("Confirmed submission in modal")
|
||||||
|
|
||||||
# Step 13: Handle feedback if present
|
# Step 13: Wait for success modal (appears after confirmation)
|
||||||
|
# Success modal auto-closes after 2 seconds, then feedback modal appears
|
||||||
|
try:
|
||||||
|
if domain_assessment_page.is_success_modal_present():
|
||||||
|
steps_completed.append("Success modal appeared")
|
||||||
|
# Wait for success modal to auto-close (2 seconds + buffer)
|
||||||
|
time.sleep(3) # Wait for auto-close (2s) + buffer
|
||||||
|
# Wait for modal to disappear
|
||||||
|
domain_assessment_page.close_success_modal()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Step 14: Handle feedback modal (appears after success modal closes)
|
||||||
try:
|
try:
|
||||||
feedback_page = DomainFeedbackPage(driver)
|
feedback_page = DomainFeedbackPage(driver)
|
||||||
|
# Wait for feedback modal to appear (with retry)
|
||||||
|
feedback_modal_present = False
|
||||||
|
for i in range(10): # Wait up to 10 seconds
|
||||||
if feedback_page.is_modal_present():
|
if feedback_page.is_modal_present():
|
||||||
|
feedback_modal_present = True
|
||||||
|
break
|
||||||
|
RandomizedWait.wait_for_page_load('modal')
|
||||||
|
|
||||||
|
if feedback_modal_present:
|
||||||
feedback_page.submit_feedback(
|
feedback_page.submit_feedback(
|
||||||
question1_answer='yes',
|
question1_yes=True,
|
||||||
question1_justification='Automated load test response',
|
question1_justification='Automated load test response',
|
||||||
question2_answer='This is an automated load test response for backend analysis.'
|
question2_text='This is an automated load test response for backend analysis.'
|
||||||
)
|
)
|
||||||
RandomizedWait.wait_for_submission('feedback')
|
RandomizedWait.wait_for_submission('feedback')
|
||||||
steps_completed.append("Submitted feedback")
|
steps_completed.append("Submitted domain feedback")
|
||||||
except:
|
except Exception as e:
|
||||||
|
print(f"⚠️ Error handling feedback: {e}")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
duration = time.time() - start_time
|
duration = time.time() - start_time
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user