Skip to content

Commit

Permalink
teacherCreatesCourseCOT4oMiniTest passing!
Browse files Browse the repository at this point in the history
  • Loading branch information
augustocristian committed Jul 30, 2024
1 parent 0718b32 commit ebe6bca
Showing 1 changed file with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,36 +196,35 @@ void teacherCreatesCourseCOT4oMiniTest() throws ElementNotFoundException {
String teacherEmail = "[email protected]"; // Replace with actual test data
String teacherPassword = "pass"; // Replace with actual test data
String courseTitle = "Test Course Title"; // Replace with desired course title
String courseImagePath = "path/to/image.jpg"; // Replace with actual image path if needed


// Step 1: Login as Teacher
this.slowLogin(user, teacherEmail, teacherPassword);

// Step 2: Navigate to Course Creation Page
NavigationUtilities.toCoursesHome(driver);
Click.element(driver, By.id("create-course-button")); // Replace with actual button ID
Click.element(driver, By.id("add-course-icon")); // Replace with actual button ID

// Step 3: Fill in Course Details
WebElement titleInput = driver.findElement(By.id("course-title")); // Replace with actual input ID
WebElement titleInput = driver.findElement(By.id("input-post-course-name")); // Replace with actual input ID
titleInput.sendKeys(courseTitle);

// Optional: Upload an image if applicable
if (courseImagePath != null && !courseImagePath.isEmpty()) {
WebElement imageUpload = driver.findElement(By.id("course-image-upload")); // Replace with actual upload ID
imageUpload.sendKeys(courseImagePath);
}
WebElement fileInput = driver.findElement(By.id("inputPostCourseImage"));
File uploadFile= new File("src/test/resources/inputs/image.png");
fileInput.sendKeys(uploadFile.getAbsolutePath());


Click.element(driver, By.id("create-course-submit")); // Replace with actual submit button ID
Click.element(driver, By.id("submit-post-course-btn")); // Replace with actual submit button ID

// Step 4: Verify Course Creation
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.id("dashboard"))); // Wait for dashboard to load
List<WebElement> courses = driver.findElements(By.className("course-title")); // Replace with actual class name
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.className("dashboard-title"))); // Wait for dashboard to load
List<WebElement> courses = driver.findElements(By.xpath("//*[contains(text(), '" + courseTitle + "')]")); // Replace with actual class name
boolean courseCreated = courses.stream().anyMatch(course -> course.getText().equals(courseTitle));

Assertions.assertTrue(courseCreated, "The course was not created successfully.");

// Step 5: Teardown
Click.element(driver, By.id("logout-button")); // Replace with actual logout button ID
//Click.element(driver, By.id("logout-button")); // Replace with actual logout button ID Its done by the base Test Class
}

}

0 comments on commit ebe6bca

Please sign in to comment.