Skip to content

Commit

Permalink
teacherCreatesCourseFS4oMiniTest passing!
Browse files Browse the repository at this point in the history
  • Loading branch information
augustocristian committed Jul 30, 2024
1 parent e417769 commit 0718b32
Showing 1 changed file with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,31 +158,30 @@ void teacherCreatesCourseFS4oMiniTest() {
// Log in with provided credentials
this.slowLogin(user, teacherEmail, teacherPassword);
String courseTitle = "New Course Title";
String courseImagePath = "path/to/image.jpg"; // Optional image path

try {
// Navigate to course creation page
NavigationUtilities.toCoursesHome(driver);

// Press the add course button
WebElement createCourseButton = driver.findElement(By.id("add-course-icon"));
Click.element(driver, createCourseButton);
// Enter course title
WebElement titleInput = driver.findElement(By.id("courseTitleInput")); // Adjust the locator as necessary
WebElement titleInput = driver.findElement(By.id("input-post-course-name"));// Adjust the locator as necessary
titleInput.sendKeys(courseTitle);

// Optionally upload an image
if (courseImagePath != null && !courseImagePath.isEmpty()) {
WebElement imageUploadInput = driver.findElement(By.id("courseImageUpload")); // Adjust the locator as necessary
imageUploadInput.sendKeys(courseImagePath);
}
WebElement fileInput = driver.findElement(By.id("inputPostCourseImage"));
File uploadFile= new File("src/test/resources/inputs/image.png");
fileInput.sendKeys(uploadFile.getAbsolutePath());

// Click on "Create Course" button
WebElement createCourseButton = driver.findElement(By.id("createCourseButton")); // Adjust the locator as necessary
Click.element(driver, createCourseButton);

WebElement createCourseSubmitButton = driver.findElement(By.id("submit-post-course-btn"));
createCourseSubmitButton.click();
// Wait for the course to be created and displayed in the dashboard
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[contains(text(), '" + courseTitle + "')]"))); // Adjust the locator as necessary
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[contains(text(), '" + courseTitle + "')]"))); // Adjust the locator as necessary

// Verify that the new course appears in the teacher's dashboard
List<WebElement> courses = driver.findElements(By.xpath("//div[contains(@class, 'course-title')]")); // Adjust the locator as necessary
List<WebElement> courses = driver.findElements(By.xpath("//*[contains(@class, 'course-title')]")); // Adjust the locator as necessary
boolean courseCreated = courses.stream().anyMatch(course -> course.getText().equals(courseTitle));
assertTrue(courseCreated, "The course was not created successfully and does not appear in the dashboard.");

Expand Down

0 comments on commit 0718b32

Please sign in to comment.