LRR/test/SeleniumMpiana/README.md

2.5 KiB

Automated Testing with Selenium

Prerequisites

  • Python 3 installed
  • Chrome browser installed
  • ChromeDriver downloaded and added to the system PATH (Download ChromeDriver)
  • MySQL Database configured with appropriate credentials

Running the Tests :

Configure Database Restoration:

  • Open test_assign_ta.py.
  • Update the PASSWORD variable in the restore_database fixture with your MySQL root password.
  • Running the Tests
  • Open the test_assign_ta.py file and update the following variables with your login credentials:
    courses_to_test = [
        {"id": 1, "name": "Your Course Name 1", "ta_assignments": {" Your TA Name 1": "Ta assigned successfully."}},
        {"id": 2, "name": "Your Course Name 2", "ta_assignments": {"Your TA Name 2": "The selected TA is already assigned to this course."}},
        # Add more courses as needed , also make sure the informations your entering is correct and same in your database ! 

        # for exemple if you have a Ta named : [MPIANA] in your database and in the script you write [mpiana]. it will result on error or failed.
    ]

Run the tests with this command :

  • pytest test_assign_ta.py

How It Works :

  • The login function logs into the web application using the provided credentials.

  • After successful login, the script waits for redirection to the Admin page and verifies the URL.

  • The assign_ta function assigns a Teaching Assistant (TA) to a course and handles any alerts that may occur.

  • The tests in test_assign_ta.py use the pytest framework to run multiple test cases for TA assignments.

  • Test results, including success and failure information, are printed to the console and logged in test_results.txt.

  • Note: Ensure that the URLs and element locators in the code match the structure of the web application you are testing. Adjustments may be necessary based on the actual HTML structure.

  • Feel free to customize the list of courses and test cases based on the TAs and courses available in your instance of the web application.

  • For database restoration, make sure to provide the correct MySQL root password in the restore_database fixture. If any issues occur during testing, check the console output and logs for troubleshooting.

Contact: @Mpiana_diego.