From 4a9b0156b4a33e0f4e86b7cd1ddcd17aaebc80cf Mon Sep 17 00:00:00 2001 From: Augusto Date: Sat, 17 Aug 2024 00:17:03 +0200 Subject: [PATCH] Dealing with zombie processes --- .../no_elastest/common/BaseLoggedTest.java | 36 +-- .../e2e/no_elastest/common/BrowserUser.java | 2 - .../e2e/no_elastest/common/ChromeUser.java | 24 +- .../e2e/no_elastest/common/EdgeUser.java | 9 +- .../e2e/no_elastest/common/FirefoxUser.java | 11 +- .../common/ForumNavigationUtilities.java | 4 +- .../common/NavigationUtilities.java | 2 - .../common/SessionNavigationUtilities.java | 2 +- .../no_elastest/common/SpiderNavigation.java | 21 +- .../e2e/no_elastest/common/UserUtilities.java | 2 - .../functional/test/LoggedForumTest.java | 26 +- .../functional/test/LoggedLinksTests.java | 2 +- .../no_elastest/functional/test/UserTest.java | 4 +- .../media/FullTeachingEndToEndEChatTests.java | 42 +-- .../media/FullTeachingEndToEndRESTTests.java | 248 +++++++++--------- .../FullTeachingLoggedVideoSessionTests.java | 41 +-- ...TeachingTestEndToEndVideoSessionTests.java | 52 ++-- .../test/student/CourseStudentTest.java | 2 +- .../test/teacher/CourseTeacherTest.java | 22 +- 19 files changed, 269 insertions(+), 283 deletions(-) diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/common/BaseLoggedTest.java b/src/test/java/com/fullteaching/e2e/no_elastest/common/BaseLoggedTest.java index 9863d0e..6f7060d 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/common/BaseLoggedTest.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/common/BaseLoggedTest.java @@ -20,6 +20,8 @@ import java.io.FileInputStream; import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URISyntaxException; import java.util.Date; import java.util.List; import java.util.Properties; @@ -48,7 +50,7 @@ public class BaseLoggedTest { protected final static int DEPTH = 3; public WebDriver driver; - protected BrowserUser teacher; + protected BrowserUser user; protected BrowserUser student; protected List studentBrowserUserList; @@ -107,18 +109,18 @@ static void setupAll() { // 28 lines } @BeforeEach - void setup(TestInfo info) { //65 lines + void setup(TestInfo info) throws URISyntaxException, MalformedURLException { //65 lines log.info("##### Start test: {}" , info.getTestMethod().get().getName()); TJOB_NAME = System.getProperty("dirtarget"); - teacher = setupBrowser("chrome", TJOB_NAME + "_" + info.getTestMethod().get().getName(), "Teacher", WAIT_SECONDS); + this.user = setupBrowser("chrome", TJOB_NAME + "_" + info.getTestMethod().get().getName(), "Teacher", WAIT_SECONDS); - driver = teacher.getDriver(); + this.driver = this.user.getDriver(); } protected BrowserUser setupBrowser(String browser, String testName, - String userIdentifier, int secondsOfWait) { + String userIdentifier, int secondsOfWait) throws URISyntaxException, MalformedURLException { BrowserUser u; log.info("Starting browser ({})", browser); @@ -158,18 +160,18 @@ protected BrowserUser setupBrowser(String browser, String testName, @AfterEach void tearDown(TestInfo info) { //13 lines - if (this.teacher != null) { - log.info("##### Finish test: {} - Driver {}", info.getTestMethod().get().getName(), this.teacher.getDriver()); + if (this.user != null) { + log.info("##### Finish test: {} - Driver {}", info.getTestMethod().get().getName(), this.user.getDriver()); log.info("Browser console at the end of the test"); - LogEntries logEntries = teacher.getDriver().manage().logs().get(BROWSER); + LogEntries logEntries = user.getDriver().manage().logs().get(BROWSER); logEntries.forEach(entry -> log.info("[{}] {} {}", new Date(entry.getTimestamp()), entry.getLevel(), entry.getMessage())); - if (this.teacher.isOnSession()) { - this.logout(this.teacher); + if (this.user.isOnSession()) { + this.logout(this.user); } - this.teacher.dispose(); + this.user.dispose(); } if (this.student != null) { @@ -179,7 +181,6 @@ void tearDown(TestInfo info) { //13 lines logEntries.forEach(entry -> log.info("[{}] {} {}", new Date(entry.getTimestamp()), entry.getLevel(), entry.getMessage())); - //TO-DO- ERROR with the logout if (this.student.isOnSession()) { this.logout(student); } @@ -243,8 +244,11 @@ private void login(BrowserUser user, String userEmail, String userPass, try { userName = getUserName(user, true, APP_URL); } catch (NotLoggedException | ElementNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + if (e.getClass().isInstance(NotLoggedException.class)){ + log.error("The user {} was not logged",user.getClientData());} + else{ + log.error("The userName field not found" ); + } } log.info("Logging in successful for user {}", user.getClientData()); @@ -327,7 +331,7 @@ protected void openDialog(String cssSelector, BrowserUser user) { "//div[contains(@class, 'modal-overlay') and contains(@style, 'opacity: 0.5')]")), "Dialog not opened"); - log.info("Dialog opened for user {}", user.getClientData()); + log.info("Dialog opened using css selector for user {}", user.getClientData()); } protected void openDialog(WebElement el, BrowserUser user) {//8lines @@ -339,7 +343,7 @@ protected void openDialog(WebElement el, BrowserUser user) {//8lines user.waitUntil(ExpectedConditions.presenceOfElementLocated(By.xpath( "//div[contains(@class, 'modal-overlay') and contains(@style, 'opacity: 0.5')]")), "Dialog not opened"); - log.info("Dialog opened for user {}", user.getClientData()); + log.info("Dialog using webelement for user {}", user.getClientData()); } protected void waitForDialogClosed(String dialogId, String errorMessage, diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/common/BrowserUser.java b/src/test/java/com/fullteaching/e2e/no_elastest/common/BrowserUser.java index 7c23457..3be0dd4 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/common/BrowserUser.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/common/BrowserUser.java @@ -26,8 +26,6 @@ import java.time.Duration; -import static java.lang.invoke.MethodHandles.lookup; -import static org.slf4j.LoggerFactory.getLogger; public class BrowserUser { diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/common/ChromeUser.java b/src/test/java/com/fullteaching/e2e/no_elastest/common/ChromeUser.java index e9d8f27..a64bfec 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/common/ChromeUser.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/common/ChromeUser.java @@ -25,7 +25,8 @@ import org.openqa.selenium.support.ui.WebDriverWait; import java.net.MalformedURLException; -import java.net.URL; +import java.net.URI; +import java.net.URISyntaxException; import java.text.SimpleDateFormat; import java.time.Duration; import java.time.LocalDateTime; @@ -41,7 +42,7 @@ public class ChromeUser extends BrowserUser { ChromeOptions options = new ChromeOptions(); - public ChromeUser(String userName, int timeOfWaitInSeconds, String testName, String userIdentifier) { + public ChromeUser(String userName, int timeOfWaitInSeconds, String testName, String userIdentifier) throws URISyntaxException, MalformedURLException { super(userName, timeOfWaitInSeconds); log.info("Starting the configuration of the web browser"); log.debug(String.format("The Test name is: %s", testName)); @@ -51,15 +52,9 @@ public ChromeUser(String userName, int timeOfWaitInSeconds, String testName, Str options.setCapability("goog:loggingPrefs", logPrefs); //Problems with the max attempt of retry, solved with : https://github.com/aerokube/selenoid/issues/1124 solved with --disable-gpu + // options.addArguments("--disable-gpu"); Commented for the moment //Problems with flakiness due to screen resolution solved with --start-maximized - String[] arguments = {"--start-maximized"}; - - log.debug("Adding the arguments ({})", Arrays.toString(arguments)); - for (String argument : arguments - ) { - options.addArguments(argument); - } - + options.addArguments("--start-maximized"); options.setAcceptInsecureCerts(true); //This capability is to store the logs of the test case log.debug("Added Capabilities of acceptInsecureCerts and ignore alarms"); @@ -68,8 +63,6 @@ public ChromeUser(String userName, int timeOfWaitInSeconds, String testName, Str log.info("Using the Local WebDriver ()"); this.driver = new ChromeDriver(options); } else { - try { - Map selenoidOptions = new HashMap<>(); log.info("Using the remote WebDriver (Selenoid)"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH:mm"); @@ -85,7 +78,7 @@ public ChromeUser(String userName, int timeOfWaitInSeconds, String testName, Str LocalDateTime now = LocalDateTime.now(); String logName = System.getProperty("tjob_name") + "-" + dtf.format(now) + "-" + testName + "-" + userIdentifier + ".log"; String videoName = System.getProperty("tjob_name") + "-" + dtf.format(now) + "-" + testName + "-" + userIdentifier + ".mp4"; - log.debug("The data of this test would be stored into: video name " + videoName + " and the log is " + logName); + log.debug("The data of this test would be stored into: video name: {} and the log name: {} " , videoName,logName); selenoidOptions.put("enableLog", true); selenoidOptions.put("logName ", logName); @@ -97,13 +90,10 @@ public ChromeUser(String userName, int timeOfWaitInSeconds, String testName, Str //END CAPABILITIES FOR SELENOID RETORCH log.debug("Configuring the remote WebDriver "); - RemoteWebDriver remote = new RemoteWebDriver(new URL("http://selenoid:4444/wd/hub"), options); + RemoteWebDriver remote = new RemoteWebDriver(new URI("http://selenoid:4444/wd/hub").toURL(), options); log.debug("Configuring the Local File Detector"); remote.setFileDetector(new LocalFileDetector()); this.driver = remote; - } catch (MalformedURLException e) { - throw new RuntimeException("Exception creating eusApiURL", e); - } } log.debug("Configure the driver connection timeouts at ({})", this.timeOfWaitInSeconds); new WebDriverWait(driver, Duration.ofSeconds(this.timeOfWaitInSeconds)); diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/common/EdgeUser.java b/src/test/java/com/fullteaching/e2e/no_elastest/common/EdgeUser.java index 11a7811..3d46ba3 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/common/EdgeUser.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/common/EdgeUser.java @@ -24,7 +24,8 @@ import org.openqa.selenium.support.ui.WebDriverWait; import java.net.MalformedURLException; -import java.net.URL; +import java.net.URI; +import java.net.URISyntaxException; import java.text.SimpleDateFormat; import java.time.Duration; import java.time.LocalDateTime; @@ -36,7 +37,7 @@ public class EdgeUser extends BrowserUser { EdgeOptions options = new EdgeOptions(); - public EdgeUser(String userName, int timeOfWaitInSeconds, String testName, String userIdentifier) { + public EdgeUser(String userName, int timeOfWaitInSeconds, String testName, String userIdentifier) throws URISyntaxException { super(userName, timeOfWaitInSeconds); log.info(String.format("The Test names are: %s", testName)); @@ -67,7 +68,7 @@ public EdgeUser(String userName, int timeOfWaitInSeconds, String testName, Strin LocalDateTime now = LocalDateTime.now(); String logName = dtf.format(now) + "-" + testName + "-" + userIdentifier + ".log"; String videoName = dtf.format(now) + "_" + testName + "_" + userIdentifier + ".mp4"; - log.debug("The data of this test would be stored into: video name " + videoName + " and the log is " + logName); + log.debug("The data of this test would be stored into: video name {} and the log is {}", videoName,logName); selenoidOptions.put("enableLog", true); selenoidOptions.put("logName ", logName); @@ -79,7 +80,7 @@ public EdgeUser(String userName, int timeOfWaitInSeconds, String testName, Strin //END CAPABILITIES FOR SELENOID RETORCH - RemoteWebDriver remote = new RemoteWebDriver(new URL(eusApiURL), options); + RemoteWebDriver remote = new RemoteWebDriver(new URI(eusApiURL).toURL(), options); remote.setFileDetector(new LocalFileDetector()); diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/common/FirefoxUser.java b/src/test/java/com/fullteaching/e2e/no_elastest/common/FirefoxUser.java index e8a9fc3..8ca21e4 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/common/FirefoxUser.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/common/FirefoxUser.java @@ -24,7 +24,8 @@ import org.openqa.selenium.remote.RemoteWebDriver; import java.net.MalformedURLException; -import java.net.URL; +import java.net.URI; +import java.net.URISyntaxException; import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -35,7 +36,7 @@ public class FirefoxUser extends BrowserUser { FirefoxOptions options = new FirefoxOptions(); - public FirefoxUser(String userName, int timeOfWaitInSeconds, String testName, String userIdentifier) { + public FirefoxUser(String userName, int timeOfWaitInSeconds, String testName, String userIdentifier) throws URISyntaxException { super(userName, timeOfWaitInSeconds); //TO-DO Firefox configuration has changed, review it. FirefoxProfile profile = new FirefoxProfile(); @@ -74,8 +75,7 @@ public FirefoxUser(String userName, int timeOfWaitInSeconds, String testName, St LocalDateTime now = LocalDateTime.now(); String logName = dtf.format(now) + "-" + testName + "-" + userIdentifier + ".log"; String videoName = dtf.format(now) + "_" + testName + "_" + userIdentifier + ".mp4"; - log.debug("The data of this test would be stored into: video name " + videoName + " and the log is " + logName); - + log.debug("The data of this test would be stored into: video name {} and the log is {}", videoName,logName); selenoidOptions.put("enableLog", true); selenoidOptions.put("logName ", logName); selenoidOptions.put("videoName", videoName); @@ -86,7 +86,7 @@ public FirefoxUser(String userName, int timeOfWaitInSeconds, String testName, St //END CAPABILITIES FOR SELENOID RETORCH - RemoteWebDriver remote = new RemoteWebDriver(new URL(eusApiURL), options); + RemoteWebDriver remote = new RemoteWebDriver(new URI(eusApiURL).toURL(), options); remote.setFileDetector(new LocalFileDetector()); @@ -99,7 +99,6 @@ public FirefoxUser(String userName, int timeOfWaitInSeconds, String testName, St } } - //this.driver.manage().timeouts().setScriptTimeout(this.timeOfWaitInSeconds, TimeUnit.SECONDS); this.configureDriver(); } diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/common/ForumNavigationUtilities.java b/src/test/java/com/fullteaching/e2e/no_elastest/common/ForumNavigationUtilities.java index 8818230..6f4b3d9 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/common/ForumNavigationUtilities.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/common/ForumNavigationUtilities.java @@ -15,10 +15,8 @@ import java.util.List; import static com.fullteaching.e2e.no_elastest.common.Constants.*; -import static java.lang.invoke.MethodHandles.lookup; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.slf4j.LoggerFactory.getLogger; public class ForumNavigationUtilities { @@ -72,7 +70,7 @@ public static WebElement getEntry(WebDriver wd, String entry_name) throws Elemen try { WebElement title = entry.findElement(FORUM_ENTRY_LIST_ENTRY_TITLE); String title_text = title.getText(); - if (title_text == null || title_text.equals("")) { + if (title_text == null || title_text.isEmpty()) { title_text = title.getAttribute("innerHTML"); } if (entry_name.equals(title_text)) { diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/common/NavigationUtilities.java b/src/test/java/com/fullteaching/e2e/no_elastest/common/NavigationUtilities.java index 9e8c469..e0464f6 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/common/NavigationUtilities.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/common/NavigationUtilities.java @@ -13,8 +13,6 @@ import static com.fullteaching.e2e.no_elastest.common.BaseLoggedTest.HOST; import static com.fullteaching.e2e.no_elastest.common.Constants.*; -import static java.lang.invoke.MethodHandles.lookup; -import static org.slf4j.LoggerFactory.getLogger; public class NavigationUtilities { diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/common/SessionNavigationUtilities.java b/src/test/java/com/fullteaching/e2e/no_elastest/common/SessionNavigationUtilities.java index 97bb89a..c5afdb3 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/common/SessionNavigationUtilities.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/common/SessionNavigationUtilities.java @@ -29,7 +29,7 @@ public static WebElement getSession(WebDriver wd, String session_name) throws El try { WebElement title = session.findElement(SESSION_LIST_SESSION_NAME); String title_text = title.getText(); - if (title_text == null || title_text.equals("")) { + if (title_text == null || title_text.isEmpty()) { title_text = title.getAttribute("innerHTML"); } if (session_name.equals(title_text)) { diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/common/SpiderNavigation.java b/src/test/java/com/fullteaching/e2e/no_elastest/common/SpiderNavigation.java index ee8dfaf..9a342f8 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/common/SpiderNavigation.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/common/SpiderNavigation.java @@ -35,10 +35,9 @@ public static List getPageLinks(WebDriver wd) { //29 lines List a_lst = wd.findElements(By.tagName("a")); for (WebElement a : a_lst) { String href = a.getAttribute("href"); - if ((href != null) && (!href.trim().equals("")) && (!href.contains("#"))) { - if (isContainedIn(href.trim(), links_href) && href.contains(host)) + if ((href != null) && (!href.trim().isEmpty()) && (!href.contains("#")) && isContainedIn(href.trim(), links_href) && href.contains(host)) links.add(a); - } + } return links; } @@ -54,10 +53,8 @@ public static List getUnexploredPageLinks(WebDriver wd, Map allLinks = getPageLinks(wd); for (WebElement a : allLinks) { String href = a.getAttribute("href"); - if ((href != null) && (!href.trim().equals("")) && (!href.contains("#"))) { - if (isContainedIn(href.trim(), explored.keySet()) && href.contains(host)) //8lines - links.add(a); - } + if ((href != null) && (!href.trim().isEmpty()) && (!href.contains("#")) && isContainedIn(href.trim(), explored.keySet()) && href.contains(host)) + links.add(a); } return links; } @@ -102,20 +99,18 @@ private static boolean isContainedIn(String href, Set set) { // 8lines } public static Set addNonExistentLink(Set original, String href) { //5lines - if ((href != null) && (!href.equals("")) && (!href.contains("#"))) { - if (isContainedIn(href, original) && href.contains(host)) + if ((href != null) && (!href.isEmpty()) && (!href.contains("#")) && isContainedIn(href, original) && href.contains(host)) original.add(href); - } + return original; } public static List discardExplored(List new_links, Set explored) { //8 lines List withOutExplored = new ArrayList<>(); for (String href : new_links) { - if ((href != null) && (!href.equals("")) && (!href.contains("#"))) { - if (isContainedIn(href, explored) && href.contains(host)) + if ((href != null) && (!href.isEmpty()) && (!href.contains("#")) && isContainedIn(href, explored) && href.contains(host)) withOutExplored.add(href); - } + } return withOutExplored; } diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/common/UserUtilities.java b/src/test/java/com/fullteaching/e2e/no_elastest/common/UserUtilities.java index 2addef3..5a3d84d 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/common/UserUtilities.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/common/UserUtilities.java @@ -14,8 +14,6 @@ import org.slf4j.LoggerFactory; import static com.fullteaching.e2e.no_elastest.common.Constants.*; -import static java.lang.invoke.MethodHandles.lookup; -import static org.slf4j.LoggerFactory.getLogger; public class UserUtilities { diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/LoggedForumTest.java b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/LoggedForumTest.java index 1521fa6..4fa355c 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/LoggedForumTest.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/LoggedForumTest.java @@ -66,7 +66,7 @@ public static Stream data() throws IOException { @ParameterizedTest @MethodSource("data") void forumLoadEntriesTest(String mail, String password, String role) { //47lines +115 +28 set up +13 lines teardown =203 - this.slowLogin(teacher, mail, password);//24 lines + this.slowLogin(user, mail, password);//24 lines try { //navigate to courses. NavigationUtilities.toCoursesHome(driver);//3lines @@ -135,7 +135,7 @@ void forumLoadEntriesTest(String mail, String password, String role) { //47lines @ParameterizedTest @MethodSource("data") void forumNewEntryTest(String mail, String password, String role) {// 48+ 104 + 28 set up +13 lines teardown =193 - this.slowLogin(teacher, mail, password); //24 lines + this.slowLogin(user, mail, password); //24 lines Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); int mYear = calendar.get(Calendar.YEAR); @@ -191,7 +191,7 @@ void forumNewEntryTest(String mail, String password, String role) {// 48+ 104 + Assertions.fail("Failed to navigate to course forum:: " + notFoundException.getClass() + ": " + notFoundException.getLocalizedMessage()); } //Fix Flaky test Navigating to the mainpage to logout... - teacher.getDriver().get(APP_URL); + user.getDriver().get(APP_URL); } /** @@ -213,7 +213,7 @@ void forumNewEntryTest(String mail, String password, String role) {// 48+ 104 + @ParameterizedTest @MethodSource("data") void forumNewCommentTest(String mail, String password, String role) { // 69+142 + 28 set up +13 lines teardown =252 - this.slowLogin(teacher, mail, password); //24 lines + this.slowLogin(user, mail, password); //24 lines Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); int mYear = calendar.get(Calendar.YEAR); @@ -259,8 +259,8 @@ void forumNewCommentTest(String mail, String password, String role) { // 69+142 Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(FORUM_COMMENT_LIST)); //TO-DO think in other better way to solve this problem Wait.waitForPageLoaded(driver); - teacher.waitUntil(ExpectedConditions.visibilityOfElementLocated(FORUM_COMMENT_LIST_COMMENT), "The comment list are not visible"); - teacher.waitUntil((ExpectedCondition) driver -> { + user.waitUntil(ExpectedConditions.visibilityOfElementLocated(FORUM_COMMENT_LIST_COMMENT), "The comment list are not visible"); + user.waitUntil((ExpectedCondition) driver -> { int elementCount = ForumNavigationUtilities.getComments(driver).size(); return elementCount > numberCommentsOld; }, "Comment not attached"); @@ -268,7 +268,7 @@ void forumNewCommentTest(String mail, String password, String role) { // 69+142 //asserts assertTrue(comments.size() > numberCommentsOld, "Comment list empty or only original comment"); - teacher.waitUntil(ExpectedConditions.visibilityOfElementLocated(FORUM_COMMENT_LIST_COMMENT), "The comment list are not visible"); + user.waitUntil(ExpectedConditions.visibilityOfElementLocated(FORUM_COMMENT_LIST_COMMENT), "The comment list are not visible"); boolean commentFound = false; for (WebElement comment : comments) { @@ -310,7 +310,7 @@ void forumNewCommentTest(String mail, String password, String role) { // 69+142 @ParameterizedTest @MethodSource("data") void forumNewReply2CommentTest(String mail, String password, String role) { // 63+137+ 28 set up +13 lines teardown = 242 - this.slowLogin(teacher, mail, password);//24 lines + this.slowLogin(user, mail, password);//24 lines Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); int mYear = calendar.get(Calendar.YEAR); @@ -351,14 +351,14 @@ void forumNewReply2CommentTest(String mail, String password, String role) { // 6 Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(FORUM_COMMENT_LIST_MODAL_NEW_REPLY)); WebElement textField = driver.findElement(FORUM_COMMENT_LIST_MODAL_NEW_REPLY_TEXT_FIELD); textField.sendKeys(newReplyContent); - Click.element(teacher.getDriver(), FORUM_NEW_COMMENT_MODAL_POST_BUTTON); + Click.element(user.getDriver(), FORUM_NEW_COMMENT_MODAL_POST_BUTTON); - teacher.waitUntil(ExpectedConditions.visibilityOfElementLocated(FORUM_COMMENT_LIST), "The comments are not visible"); + user.waitUntil(ExpectedConditions.visibilityOfElementLocated(FORUM_COMMENT_LIST), "The comments are not visible"); - teacher.waitUntil(ExpectedConditions.visibilityOfElementLocated(FORUM_COMMENT_LIST_COMMENT), "The comment list are not visible"); - comments = ForumNavigationUtilities.getComments(teacher.getDriver()); //2lines + user.waitUntil(ExpectedConditions.visibilityOfElementLocated(FORUM_COMMENT_LIST_COMMENT), "The comment list are not visible"); + comments = ForumNavigationUtilities.getComments(user.getDriver()); //2lines //getComment replies - List replies = ForumNavigationUtilities.getReplies(teacher.getDriver(), comments.get(0)); // 7 lines + List replies = ForumNavigationUtilities.getReplies(user.getDriver(), comments.get(0)); // 7 lines WebElement newReply = null; for (WebElement reply : replies) { diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/LoggedLinksTests.java b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/LoggedLinksTests.java index df9a7cb..afe2bc6 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/LoggedLinksTests.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/LoggedLinksTests.java @@ -48,7 +48,7 @@ public static Stream data() throws IOException { @MethodSource("data") @DisplayName("spiderLoggedTest") void spiderLoggedTest(String mail, String password, String role) { //140 + 28 set up +13 lines teardown = 181 - this.slowLogin(teacher, mail, password); + this.slowLogin(user, mail, password); //*navigate from home*//* NavigationUtilities.getUrlAndWaitFooter(driver, HOST); //13 lines List pageLinks = SpiderNavigation.getPageLinks(driver); //29 lines diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/UserTest.java b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/UserTest.java index 808004a..2b1184a 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/UserTest.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/UserTest.java @@ -43,7 +43,7 @@ public static Stream data() throws IOException { @DisplayName("loginTest") void loginTest(String mail, String password, String role) { //22 +85 +28 set up +13 lines teardown =148 try { - this.slowLogin(teacher, mail, password); //24 lines + this.slowLogin(user, mail, password); //24 lines UserUtilities.checkLogin(driver, mail); //12 lines assertTrue(true, "not logged"); } catch (NotLoggedException | BadUserException e) { @@ -54,7 +54,7 @@ void loginTest(String mail, String password, String role) { //22 +85 +28 set up fail(e.getLocalizedMessage()); } try { - this.logout(teacher); //14 lines + this.logout(user); //14 lines UserUtilities.checkLogOut(driver); //8lines } catch (ElementNotFoundException eleNotFoundExcept) { fail("Still logged"); diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingEndToEndEChatTests.java b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingEndToEndEChatTests.java index b53b7cf..16b3a1f 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingEndToEndEChatTests.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingEndToEndEChatTests.java @@ -31,6 +31,8 @@ import org.openqa.selenium.support.ui.ExpectedConditions; import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URISyntaxException; import java.util.List; import java.util.stream.Stream; @@ -65,29 +67,29 @@ public static Stream data() throws IOException { @ParameterizedTest @MethodSource("data") @Tag("Multiuser Test") - void oneToOneChatInSessionChrome(String mail, String password, String role ) { //197 Lines of code + void oneToOneChatInSessionChrome(String mail, String password, String role ) throws URISyntaxException, MalformedURLException { //197 Lines of code int numberpriormessages; // TEACHER - this.slowLogin(teacher, mail, password);//24 + this.slowLogin(user, mail, password);//24 - log.info("{} entering first course", teacher.getClientData()); - teacher.getWaiter().until(ExpectedConditions.presenceOfElementLocated( + log.info("{} entering first course", user.getClientData()); + user.getWaiter().until(ExpectedConditions.presenceOfElementLocated( By.cssSelector(("ul.collection li.collection-item:first-child div.course-title")))); - teacher.getDriver().findElement(By.cssSelector("ul.collection li.collection-item:first-child div.course-title")) + user.getDriver().findElement(By.cssSelector("ul.collection li.collection-item:first-child div.course-title")) .click(); - log.info("{} navigating to 'Sessions' tab", teacher.getClientData()); - teacher.getWaiter().until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(("#md-tab-label-0-1")))); - teacher.getDriver().findElement(By.cssSelector("#md-tab-label-0-1")).click(); + log.info("{} navigating to 'Sessions' tab", user.getClientData()); + user.getWaiter().until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(("#md-tab-label-0-1")))); + user.getDriver().findElement(By.cssSelector("#md-tab-label-0-1")).click(); - log.info("{} getting into first session", teacher.getClientData()); - teacher.getDriver().findElement(By.cssSelector("ul div:first-child li.session-data div.session-ready")).click(); - teacher.waitUntil(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#fixed-icon")), "Element fixed-icon not clickable"); + log.info("{} getting into first session", user.getClientData()); + user.getDriver().findElement(By.cssSelector("ul div:first-child li.session-data div.session-ready")).click(); + user.waitUntil(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#fixed-icon")), "Element fixed-icon not clickable"); // Check connected message - teacher.getDriver().findElement(By.cssSelector("#fixed-icon")).click(); + user.getDriver().findElement(By.cssSelector("#fixed-icon")).click(); - checkSystemMessage("Connected", teacher, 100); // 6 lines + checkSystemMessage("Connected", user, 100); // 6 lines // STUDENT student = setupBrowser(STUDENT_BROWSER, TJOB_NAME + "_" +"oneToOneChatInSessionChrome-STUDENT", studentMail,5);//27 lines @@ -106,26 +108,26 @@ void oneToOneChatInSessionChrome(String mail, String password, String role ) { / checkSystemMessage("Connected", student, 0); //6 lines - checkSystemMessage(STUDENT_NAME + " has connected", teacher, 100); //6 lines + checkSystemMessage(STUDENT_NAME + " has connected", user, 100); //6 lines checkSystemMessage(TEACHER_NAME + " has connected", student, 100);//6lines // Test chat String teacherMessage = "TEACHER CHAT MESSAGE"; String studentMessage = "STUDENT CHAT MESSAGE"; - numberpriormessages = getNumberMessages(teacher); - WebElement chatInputTeacher = teacher.getDriver().findElement(By.id("message")); + numberpriormessages = getNumberMessages(user); + WebElement chatInputTeacher = user.getDriver().findElement(By.id("message")); chatInputTeacher.sendKeys(teacherMessage); - teacher.getWaiter().until(ExpectedConditions.elementToBeClickable(By.id("send-btn"))); - teacher.getDriver().findElement(By.id("send-btn")).click(); + user.getWaiter().until(ExpectedConditions.elementToBeClickable(By.id("send-btn"))); + user.getDriver().findElement(By.id("send-btn")).click(); - checkOwnMessage(teacherMessage, TEACHER_NAME, teacher, numberpriormessages);//7 lines + checkOwnMessage(teacherMessage, TEACHER_NAME, user, numberpriormessages);//7 lines checkStrangerMessage(teacherMessage, TEACHER_NAME, student, numberpriormessages); //8lines numberpriormessages = getNumberMessages(student); WebElement chatInputStudent = student.getDriver().findElement(By.id("message")); chatInputStudent.sendKeys(studentMessage); student.getWaiter().until(ExpectedConditions.elementToBeClickable(By.id("send-btn"))); student.getDriver().findElement(By.id("send-btn")).click(); - checkStrangerMessage(studentMessage, STUDENT_NAME, teacher, numberpriormessages); //8lines + checkStrangerMessage(studentMessage, STUDENT_NAME, user, numberpriormessages); //8lines checkOwnMessage(studentMessage, STUDENT_NAME, student, numberpriormessages);//7lines diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingEndToEndRESTTests.java b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingEndToEndRESTTests.java index 93153bb..7024a20 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingEndToEndRESTTests.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingEndToEndRESTTests.java @@ -82,26 +82,26 @@ void courseRestOperations(String mail, String password, String role ) throws Ele editCourse(); - CourseNavigationUtilities.deleteCourse(teacher.getDriver(), COURSE_NAME + EDITED); // Tear down + CourseNavigationUtilities.deleteCourse(user.getDriver(), COURSE_NAME + EDITED); // Tear down } private void loginAndCreateNewCourse(String mail, String password) throws ElementNotFoundException { - slowLogin(teacher, mail, password); - CourseNavigationUtilities.newCourse(teacher.getDriver(), COURSE_NAME); + slowLogin(user, mail, password); + CourseNavigationUtilities.newCourse(user.getDriver(), COURSE_NAME); } private void editCourse() { log.info("Editing course"); String editedCourseName = COURSE_NAME + EDITED; - List editIcons = teacher.getDriver().findElements(By.className("course-put-icon")); - openDialog(editIcons.get(editIcons.size() - 1), teacher); - teacher.waitUntil(ExpectedConditions.elementToBeClickable(By.id("input-put-course-name")), "Input for course name not clickable"); - WebElement courseNameInput = teacher.getDriver().findElement(By.id("input-put-course-name")); + List editIcons = user.getDriver().findElements(By.className("course-put-icon")); + openDialog(editIcons.get(editIcons.size() - 1), user); + user.waitUntil(ExpectedConditions.elementToBeClickable(By.id("input-put-course-name")), "Input for course name not clickable"); + WebElement courseNameInput = user.getDriver().findElement(By.id("input-put-course-name")); courseNameInput.clear(); courseNameInput.sendKeys(editedCourseName); - teacher.getDriver().findElement(By.id("submit-put-course-btn")).click(); - waitForDialogClosed("course-modal", "Edition of course failed", teacher); - teacher.waitUntil(ExpectedConditions.textToBe(By.cssSelector("#course-list .course-list-item:last-child div.course-title span"), editedCourseName), "Unexpected course name"); + user.getDriver().findElement(By.id("submit-put-course-btn")).click(); + waitForDialogClosed("course-modal", "Edition of course failed", user); + user.waitUntil(ExpectedConditions.textToBe(By.cssSelector("#course-list .course-list-item:last-child div.course-title span"), editedCourseName), "Unexpected course name"); } @Resource(resID = "LoginService", replaceable = {}) @@ -116,16 +116,16 @@ private void editCourse() { void courseInfoRestOperations(String mail, String password, String role) throws ElementNotFoundException { //12+16+65 set up +60 lines teardown =153 loginAndCreateNewCourse(mail,password); enterCourseAndNavigateTab(COURSE_NAME, "info-tab-icon");//16 lines - teacher.waitUntil(ExpectedConditions.presenceOfNestedElementLocatedBy(By.cssSelector(".md-tab-body.md-tab-active"), By.cssSelector(".card-panel.warning")), "Course info wasn't empty"); + user.waitUntil(ExpectedConditions.presenceOfNestedElementLocatedBy(By.cssSelector(".md-tab-body.md-tab-active"), By.cssSelector(".card-panel.warning")), "Course info wasn't empty"); log.info("Editing course information"); - teacher.getDriver().findElement(By.id("edit-course-info")).click(); - teacher.getDriver().findElement(By.className("ql-editor")).sendKeys(TEST_COURSE_INFO); - teacher.getDriver().findElement(By.id("send-info-btn")).click(); + user.getDriver().findElement(By.id("edit-course-info")).click(); + user.getDriver().findElement(By.className("ql-editor")).sendKeys(TEST_COURSE_INFO); + user.getDriver().findElement(By.id("send-info-btn")).click(); - teacher.waitUntil(ExpectedConditions.textToBe(By.cssSelector(".ql-editor p"), TEST_COURSE_INFO), "Unexpected course info"); + user.waitUntil(ExpectedConditions.textToBe(By.cssSelector(".ql-editor p"), TEST_COURSE_INFO), "Unexpected course info"); log.info("Course information successfully updated"); - CourseNavigationUtilities.deleteCourse(teacher.getDriver(), COURSE_NAME); + CourseNavigationUtilities.deleteCourse(user.getDriver(), COURSE_NAME); } @Resource(resID = "LoginService", replaceable = {}) @@ -146,44 +146,44 @@ void sessionRestOperations(String mail, String password, String role) throws Ele deleteSession(); - CourseNavigationUtilities.deleteCourse(teacher.getDriver(), COURSE_NAME); + CourseNavigationUtilities.deleteCourse(user.getDriver(), COURSE_NAME); } private void addNewSession() { enterCourseAndNavigateTab(COURSE_NAME, "sessions-tab-icon"); log.info("Adding new session"); - openDialog("#add-session-icon", teacher); + openDialog("#add-session-icon", user); fillSessionForm("TEST LESSON NAME", "TEST LESSON COMMENT", LocalDate.parse("2018-03-01"), LocalTime.parse("15:10"), false); - waitForDialogClosed("course-details-modal", "Addition of session failed", teacher); + waitForDialogClosed("course-details-modal", "Addition of session failed", user); verifySessionDetails("TEST LESSON NAME", "TEST LESSON COMMENT", "Jan 3, 2018 - 03:10", "Mar 1, 2018 - 15:10"); } private void editSession() { log.info("Editing session"); - openDialog(".edit-session-icon", teacher); + openDialog(".edit-session-icon", user); fillSessionForm("TEST LESSON NAME EDITED", "TEST LESSON COMMENT EDITED", LocalDate.parse("2019-04-02"), LocalTime.parse("05:10"), true); - waitForDialogClosed("put-delete-modal", "Edition of session failed", teacher); + waitForDialogClosed("put-delete-modal", "Edition of session failed", user); verifySessionDetails("TEST LESSON NAME EDITED", "TEST LESSON COMMENT EDITED", "Feb 4, 2019 - 05:10", "Apr 2, 2019 - 05:10"); } private void deleteSession() { log.info("Deleting session"); - openDialog(".edit-session-icon", teacher); - teacher.waitUntil(ExpectedConditions.elementToBeClickable(By.id(("label-delete-checkbox"))), "Checkbox for session deletion not clickable"); - teacher.getDriver().findElement(By.id("label-delete-checkbox")).click(); - teacher.waitUntil(ExpectedConditions.elementToBeClickable(By.id(("delete-session-btn"))), "Button for session deletion not clickable"); - teacher.getDriver().findElement(By.id("delete-session-btn")).click(); - waitForDialogClosed("put-delete-modal", "Deletion of session failed", teacher); - teacher.waitUntil(ExpectedConditions.numberOfElementsToBe(By.cssSelector("li.session-data"), 0), "Unexpected number of sessions"); + openDialog(".edit-session-icon", user); + user.waitUntil(ExpectedConditions.elementToBeClickable(By.id(("label-delete-checkbox"))), "Checkbox for session deletion not clickable"); + user.getDriver().findElement(By.id("label-delete-checkbox")).click(); + user.waitUntil(ExpectedConditions.elementToBeClickable(By.id(("delete-session-btn"))), "Button for session deletion not clickable"); + user.getDriver().findElement(By.id("delete-session-btn")).click(); + waitForDialogClosed("put-delete-modal", "Deletion of session failed", user); + user.waitUntil(ExpectedConditions.numberOfElementsToBe(By.cssSelector("li.session-data"), 0), "Unexpected number of sessions"); log.info("Session successfully deleted"); } private void fillSessionForm(String title, String comment, LocalDate date, LocalTime hour, boolean edit) { // Get the different fields depending on if it's editing the Session or not - WebElement titleField = teacher.getDriver().findElement(By.id(edit ? "input-put-title" : "input-post-title")); - WebElement commentField = teacher.getDriver().findElement(By.id(edit ? "input-put-comment" : "input-post-comment")); - WebElement dateField = teacher.getDriver().findElement(By.id(edit ? "input-put-date" : "input-post-date")); - WebElement timeField = teacher.getDriver().findElement(By.id(edit ? "input-put-time" : "input-post-time")); + WebElement titleField = user.getDriver().findElement(By.id(edit ? "input-put-title" : "input-post-title")); + WebElement commentField = user.getDriver().findElement(By.id(edit ? "input-put-comment" : "input-post-comment")); + WebElement dateField = user.getDriver().findElement(By.id(edit ? "input-put-date" : "input-post-date")); + WebElement timeField = user.getDriver().findElement(By.id(edit ? "input-put-time" : "input-post-time")); if (edit) { //If its editing previously clear the fields content titleField.clear(); commentField.clear(); @@ -196,18 +196,18 @@ private void fillSessionForm(String title, String comment, LocalDate date, Local dateField.sendKeys(date.format(dateFormatter)); timeField.sendKeys(hour.format(timeFormatter)); // Submit session form - teacher.getDriver().findElement(By.id(edit ? "put-modal-btn" : "post-modal-btn")).click(); + user.getDriver().findElement(By.id(edit ? "put-modal-btn" : "post-modal-btn")).click(); } private void verifySessionDetails(String expectedTitle, String expectedComment, String expectedDateTime1, String expectedDateTime2) { - teacher.waitUntil(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("li.session-data .session-title")), "Unexpected session title"); - Assertions.assertEquals(expectedTitle, teacher.getDriver().findElement(By.cssSelector("li.session-data .session-title")).getText()); + user.waitUntil(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("li.session-data .session-title")), "Unexpected session title"); + Assertions.assertEquals(expectedTitle, user.getDriver().findElement(By.cssSelector("li.session-data .session-title")).getText()); - teacher.waitUntil(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("li.session-data .session-description")), "The element located by css li.session-data .session-description is not visible"); - Assertions.assertEquals(expectedComment, teacher.getDriver().findElement(By.cssSelector("li.session-data .session-description")).getText()); + user.waitUntil(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("li.session-data .session-description")), "The element located by css li.session-data .session-description is not visible"); + Assertions.assertEquals(expectedComment, user.getDriver().findElement(By.cssSelector("li.session-data .session-description")).getText()); - teacher.waitUntil(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("li.session-data .session-datetime")), "The element located by css li.session-data .session-datetime is not visible"); - String actualDateTime = teacher.getDriver().findElement(By.cssSelector("li.session-data .session-datetime")).getText(); + user.waitUntil(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("li.session-data .session-datetime")), "The element located by css li.session-data .session-datetime is not visible"); + String actualDateTime = user.getDriver().findElement(By.cssSelector("li.session-data .session-datetime")).getText(); Assertions.assertTrue(actualDateTime.equals(expectedDateTime1) || actualDateTime.equals(expectedDateTime2)); } @@ -224,65 +224,65 @@ void forumRestOperations(String mail, String password, String role) throws Eleme loginAndCreateNewCourse(mail,password); enterCourseAndNavigateTab(COURSE_NAME, "forum-tab-icon");//16 lines log.info("Adding new entry to the forum"); - openDialog("#add-entry-icon", teacher);//8lines + openDialog("#add-entry-icon", user);//8lines // Find form elements - WebElement titleField = teacher.getDriver().findElement(By.id("input-post-title")); - WebElement commentField = teacher.getDriver().findElement(By.id("input-post-comment")); + WebElement titleField = user.getDriver().findElement(By.id("input-post-title")); + WebElement commentField = user.getDriver().findElement(By.id("input-post-comment")); String title = "TEST FORUM ENTRY"; String comment = "TEST FORUM COMMENT"; String entryDate = "a few seconds ago"; // Fill input fields titleField.sendKeys(title); commentField.sendKeys(comment); - teacher.getDriver().findElement(By.id("post-modal-btn")).click(); - waitForDialogClosed("course-details-modal", "Addition of entry failed", teacher);////14 lines + user.getDriver().findElement(By.id("post-modal-btn")).click(); + waitForDialogClosed("course-details-modal", "Addition of entry failed", user);////14 lines // Check fields of new entry - WebElement entryEl = teacher.getDriver().findElement(By.cssSelector("li.entry-title")); - teacher.waitUntil(ExpectedConditions.textToBe(By.cssSelector("li.entry-title .forum-entry-title"), title), + WebElement entryEl = user.getDriver().findElement(By.cssSelector("li.entry-title")); + user.waitUntil(ExpectedConditions.textToBe(By.cssSelector("li.entry-title .forum-entry-title"), title), "Unexpected entry title in the forum"); - teacher.waitUntil(ExpectedConditions.textToBe(By.cssSelector("li.entry-title .forum-entry-author"), TEACHER_NAME), + user.waitUntil(ExpectedConditions.textToBe(By.cssSelector("li.entry-title .forum-entry-author"), TEACHER_NAME), "Unexpected entry author in the forum"); - teacher.waitUntil(ExpectedConditions.textToBe(By.cssSelector("li.entry-title .forum-entry-date"), entryDate), + user.waitUntil(ExpectedConditions.textToBe(By.cssSelector("li.entry-title .forum-entry-date"), entryDate), "Unexpected entry date in the forum"); log.info("New entry successfully added to the forum"); log.info("Entering the new entry"); entryEl.click(); - teacher.waitUntil(ExpectedConditions.textToBe( + user.waitUntil(ExpectedConditions.textToBe( By.cssSelector(".comment-block > app-comment:first-child > div.comment-div .message-itself"), comment), "Unexpected entry title in the entry details view"); - teacher.waitUntil(ExpectedConditions.textToBe( + user.waitUntil(ExpectedConditions.textToBe( By.cssSelector(".comment-block > app-comment:first-child > div.comment-div .forum-comment-author"), TEACHER_NAME), "Unexpected entry author in the entry details view"); // Comment reply log.info("Adding new replay to the entry's only comment"); String reply = "TEST FORUM REPLY"; - openDialog(".replay-icon", teacher);//8lines - commentField = teacher.getDriver().findElement(By.id("input-post-comment")); + openDialog(".replay-icon", user);//8lines + commentField = user.getDriver().findElement(By.id("input-post-comment")); commentField.sendKeys(reply); - teacher.getDriver().findElement(By.id("post-modal-btn")).click(); - waitForDialogClosed("course-details-modal", "Addition of entry reply failed", teacher);//14 lines - teacher.waitUntil(ExpectedConditions.textToBe(By.cssSelector( + user.getDriver().findElement(By.id("post-modal-btn")).click(); + waitForDialogClosed("course-details-modal", "Addition of entry reply failed", user);//14 lines + user.waitUntil(ExpectedConditions.textToBe(By.cssSelector( ".comment-block > app-comment:first-child > div.comment-div div.comment-div .message-itself"), reply), "Unexpected reply message in the entry details view"); - teacher.waitUntil(ExpectedConditions.textToBe(By.cssSelector( + user.waitUntil(ExpectedConditions.textToBe(By.cssSelector( ".comment-block > app-comment:first-child > div.comment-div div.comment-div .forum-comment-author"), TEACHER_NAME), "Unexpected reply author in the entry details view"); log.info("Replay successfully added"); // Forum deactivation - teacher.getDriver().findElement(By.id("entries-sml-btn")).click(); + user.getDriver().findElement(By.id("entries-sml-btn")).click(); log.info("Deactivating forum"); - openDialog("#edit-forum-icon", teacher);//8lines - teacher.waitUntil(ExpectedConditions.elementToBeClickable(By.id(("label-forum-checkbox"))), + openDialog("#edit-forum-icon", user);//8lines + user.waitUntil(ExpectedConditions.elementToBeClickable(By.id(("label-forum-checkbox"))), "Checkbox for forum deactivation not clickable"); - teacher.getDriver().findElement(By.id("label-forum-checkbox")).click(); - teacher.waitUntil(ExpectedConditions.elementToBeClickable(By.id(("put-modal-btn"))), + user.getDriver().findElement(By.id("label-forum-checkbox")).click(); + user.waitUntil(ExpectedConditions.elementToBeClickable(By.id(("put-modal-btn"))), "Button for forum deactivation not clickable"); - teacher.getDriver().findElement(By.id("put-modal-btn")).click(); - waitForDialogClosed("put-delete-modal", "Deactivation of forum failed", teacher);//14 lines - teacher.waitUntil(ExpectedConditions.elementToBeClickable(By.cssSelector("app-error-message .card-panel.warning")), + user.getDriver().findElement(By.id("put-modal-btn")).click(); + waitForDialogClosed("put-delete-modal", "Deactivation of forum failed", user);//14 lines + user.waitUntil(ExpectedConditions.elementToBeClickable(By.cssSelector("app-error-message .card-panel.warning")), "Warning card (forum deactivated) missing"); log.info("Forum successfully deactivated"); - CourseNavigationUtilities.deleteCourse(teacher.getDriver(), COURSE_NAME); + CourseNavigationUtilities.deleteCourse(user.getDriver(), COURSE_NAME); } @Resource(resID = "LoginService", replaceable = {}) @@ -298,94 +298,94 @@ void filesRestOperations(String mail, String password, String role) throws Eleme loginAndCreateNewCourse(mail,password); enterCourseAndNavigateTab(COURSE_NAME, "files-tab-icon");//16 lines log.info("Checking that there are no files in the course"); - teacher.waitUntil(ExpectedConditions.elementToBeClickable(By.cssSelector("app-error-message .card-panel.warning")), + user.waitUntil(ExpectedConditions.elementToBeClickable(By.cssSelector("app-error-message .card-panel.warning")), "Warning card (course with no files) missing"); log.info("Adding new file group"); - openDialog("#add-files-icon", teacher);//8lines + openDialog("#add-files-icon", user);//8lines String fileGroup = "TEST FILE GROUP"; // Find form elements - WebElement titleField = teacher.getDriver().findElement(By.id("input-post-title")); + WebElement titleField = user.getDriver().findElement(By.id("input-post-title")); titleField.sendKeys(fileGroup); - teacher.getDriver().findElement(By.id("post-modal-btn")).click(); - waitForDialogClosed("course-details-modal", "Addition of file group failed", teacher);//14 lines + user.getDriver().findElement(By.id("post-modal-btn")).click(); + waitForDialogClosed("course-details-modal", "Addition of file group failed", user);//14 lines // Check fields of new file group - teacher.waitUntil(ExpectedConditions.textToBe(By.cssSelector(".file-group-title h5"), fileGroup), + user.waitUntil(ExpectedConditions.textToBe(By.cssSelector(".file-group-title h5"), fileGroup), "Unexpected file group name"); log.info("File group successfully added"); // Edit file group log.info("Editing file group"); - openDialog("#edit-filegroup-icon", teacher);//8lines + openDialog("#edit-filegroup-icon", user);//8lines // Find form elements - titleField = teacher.getDriver().findElement(By.id("input-file-title")); + titleField = user.getDriver().findElement(By.id("input-file-title")); titleField.clear(); titleField.sendKeys(fileGroup + EDITED); - teacher.getDriver().findElement(By.id("put-modal-btn")).click(); - waitForDialogClosed("put-delete-modal", "Edition of file group failed", teacher);//14 lines + user.getDriver().findElement(By.id("put-modal-btn")).click(); + waitForDialogClosed("put-delete-modal", "Edition of file group failed", user);//14 lines // Check fields of edited file group - teacher.waitUntil( + user.waitUntil( ExpectedConditions.textToBe(By.cssSelector("app-file-group .file-group-title h5"), fileGroup + EDITED), "Unexpected file group name"); log.info("File group successfully edited"); // Add file subgroup log.info("Adding new file sub-group"); String fileSubGroup = "TEST FILE SUBGROUP"; - openDialog(".add-subgroup-btn", teacher);//8lines - titleField = teacher.getDriver().findElement(By.id("input-post-title")); + openDialog(".add-subgroup-btn", user);//8lines + titleField = user.getDriver().findElement(By.id("input-post-title")); titleField.sendKeys(fileSubGroup); - teacher.getDriver().findElement(By.id("post-modal-btn")).click(); - waitForDialogClosed("course-details-modal", "Addition of file sub-group failed", teacher);//14 lines + user.getDriver().findElement(By.id("post-modal-btn")).click(); + waitForDialogClosed("course-details-modal", "Addition of file sub-group failed", user);//14 lines // Check fields of new file subgroup - teacher.waitUntil(ExpectedConditions.textToBe(By.cssSelector("app-file-group app-file-group .file-group-title h5"), + user.waitUntil(ExpectedConditions.textToBe(By.cssSelector("app-file-group app-file-group .file-group-title h5"), fileSubGroup), "Unexpected file sub-group name"); log.info("File sub-group successfully added"); log.info("Adding new file to sub-group"); - openDialog("app-file-group app-file-group .add-file-btn", teacher);//8lines - WebElement fileUploader = teacher.getDriver().findElement(By.className("input-file-uploader")); + openDialog("app-file-group app-file-group .add-file-btn", user);//8lines + WebElement fileUploader = user.getDriver().findElement(By.className("input-file-uploader")); String fileName = "testFile.txt"; log.info("Uploading file located on path '{}'", System.getProperty("user.dir") + "/src/test/resources/" + fileName); - teacher.runJavascript("arguments[0].setAttribute('style', 'display:block')", fileUploader); - teacher.waitUntil( + user.runJavascript("arguments[0].setAttribute('style', 'display:block')", fileUploader); + user.waitUntil( ExpectedConditions.presenceOfElementLocated(By.xpath( "//input[contains(@class, 'input-file-uploader') and contains(@style, 'display:block')]")), "Waiting for the input file to be displayed"); fileUploader.sendKeys(System.getProperty("user.dir") + "/src/test/resources/" + fileName); - teacher.getDriver().findElement(By.id("upload-all-btn")).click(); + user.getDriver().findElement(By.id("upload-all-btn")).click(); // Wait for upload - teacher.waitUntil( + user.waitUntil( ExpectedConditions.presenceOfElementLocated( By.xpath("//div[contains(@class, 'determinate') and contains(@style, 'width: 100')]")), "Upload process not completed. Progress bar not filled"); - teacher.waitUntil(ExpectedConditions.textToBe(By.xpath("//i[contains(@class, 'icon-status-upload')]"), "done"), + user.waitUntil(ExpectedConditions.textToBe(By.xpath("//i[contains(@class, 'icon-status-upload')]"), "done"), "Upload process failed"); log.info("File upload successful"); // Close dialog - teacher.getDriver().findElement(By.id("close-upload-modal-btn")).click(); - waitForDialogClosed("course-details-modal", "Upload of file failed", teacher);//14 lines + user.getDriver().findElement(By.id("close-upload-modal-btn")).click(); + waitForDialogClosed("course-details-modal", "Upload of file failed", user);//14 lines // Check new uploaded file - teacher.waitUntil(ExpectedConditions.textToBe(By.cssSelector("app-file-group app-file-group .chip .file-name-div"), + user.waitUntil(ExpectedConditions.textToBe(By.cssSelector("app-file-group app-file-group .chip .file-name-div"), fileName), "Unexpected uploaded file name"); log.info("File successfully added"); // Edit file log.info("Editing file"); - openDialog("app-file-group app-file-group .edit-file-name-icon", teacher);//8lines - titleField = teacher.getDriver().findElement(By.id("input-file-title")); + openDialog("app-file-group app-file-group .edit-file-name-icon", user);//8lines + titleField = user.getDriver().findElement(By.id("input-file-title")); titleField.clear(); String editedFileName = "testFileEDITED.txt"; titleField.sendKeys(editedFileName); - teacher.getDriver().findElement(By.id("put-modal-btn")).click(); - waitForDialogClosed("put-delete-modal", "Edition of file failed", teacher);//14 lines + user.getDriver().findElement(By.id("put-modal-btn")).click(); + waitForDialogClosed("put-delete-modal", "Edition of file failed", user);//14 lines // Check edited file name - teacher.waitUntil(ExpectedConditions.textToBe(By.cssSelector("app-file-group app-file-group .chip .file-name-div"), + user.waitUntil(ExpectedConditions.textToBe(By.cssSelector("app-file-group app-file-group .chip .file-name-div"), editedFileName), "Unexpected uploaded file name"); log.info("File successfully edited"); // Delete file group log.info("Deleting file-group"); - teacher.getDriver().findElement(By.cssSelector("app-file-group .delete-filegroup-icon")).click(); - teacher.waitUntil(ExpectedConditions.elementToBeClickable(By.cssSelector("app-error-message .card-panel.warning")), + user.getDriver().findElement(By.cssSelector("app-file-group .delete-filegroup-icon")).click(); + user.waitUntil(ExpectedConditions.elementToBeClickable(By.cssSelector("app-error-message .card-panel.warning")), "Warning card (course with no files) missing"); log.info("File group successfully deleted"); - CourseNavigationUtilities.deleteCourse(teacher.getDriver(), COURSE_NAME); + CourseNavigationUtilities.deleteCourse(user.getDriver(), COURSE_NAME); } @Resource(resID = "LoginService", replaceable = {}) @@ -401,48 +401,48 @@ void attendersRestOperations(String mail, String password, String role) throws E loginAndCreateNewCourse(mail,password); enterCourseAndNavigateTab(COURSE_NAME, "attenders-tab-icon");//16 lines log.info("Checking that there is only one attender to the course"); - teacher.waitUntil(ExpectedConditions.numberOfElementsToBe(By.className("attender-row-div"), 1), + user.waitUntil(ExpectedConditions.numberOfElementsToBe(By.className("attender-row-div"), 1), "Unexpected number of attenders for the course"); - teacher.waitUntil(ExpectedConditions.textToBe(By.cssSelector(".attender-row-div .attender-name-p"), TEACHER_NAME), + user.waitUntil(ExpectedConditions.textToBe(By.cssSelector(".attender-row-div .attender-name-p"), TEACHER_NAME), "Unexpected name for the attender"); // Add attender fail log.info("Adding attender (should FAIL)"); - openDialog("#add-attenders-icon", teacher);//8lines + openDialog("#add-attenders-icon", user);//8lines String attenderName = "studentFail@gmail.com"; - WebElement titleField = teacher.getDriver().findElement(By.id("input-attender-simple")); + WebElement titleField = user.getDriver().findElement(By.id("input-attender-simple")); titleField.sendKeys(attenderName); - teacher.getDriver().findElement(By.id("put-modal-btn")).click(); - waitForDialogClosed("put-delete-modal", "Addition of attender fail", teacher);//14 lines - teacher.waitUntil(ExpectedConditions.elementToBeClickable(By.cssSelector("app-error-message .card-panel.fail")), + user.getDriver().findElement(By.id("put-modal-btn")).click(); + waitForDialogClosed("put-delete-modal", "Addition of attender fail", user);//14 lines + user.waitUntil(ExpectedConditions.elementToBeClickable(By.cssSelector("app-error-message .card-panel.fail")), "Error card (attender not added to the course) missing"); - teacher.waitUntil(ExpectedConditions.numberOfElementsToBe(By.className("attender-row-div"), 1), + user.waitUntil(ExpectedConditions.numberOfElementsToBe(By.className("attender-row-div"), 1), "Unexpected number of attenders for the course"); - teacher.getDriver().findElement(By.cssSelector("app-error-message .card-panel.fail .material-icons")).click(); + user.getDriver().findElement(By.cssSelector("app-error-message .card-panel.fail .material-icons")).click(); log.info("Attender addition successfully failed"); // Add attender success log.info("Adding attender (should SUCCESS)"); - openDialog("#add-attenders-icon", teacher);//8lines + openDialog("#add-attenders-icon", user);//8lines attenderName = "student1@gmail.com"; - titleField = teacher.getDriver().findElement(By.id("input-attender-simple")); + titleField = user.getDriver().findElement(By.id("input-attender-simple")); titleField.sendKeys(attenderName); - teacher.getDriver().findElement(By.id("put-modal-btn")).click(); - waitForDialogClosed("put-delete-modal", "Addition of attender failed", teacher);//14 lines - teacher.waitUntil(ExpectedConditions.elementToBeClickable(By.cssSelector("app-error-message .card-panel.correct")), + user.getDriver().findElement(By.id("put-modal-btn")).click(); + waitForDialogClosed("put-delete-modal", "Addition of attender failed", user);//14 lines + user.waitUntil(ExpectedConditions.elementToBeClickable(By.cssSelector("app-error-message .card-panel.correct")), "Success card (attender properly added to the course) missing"); - teacher.waitUntil(ExpectedConditions.numberOfElementsToBe(By.className("attender-row-div"), 2), + user.waitUntil(ExpectedConditions.numberOfElementsToBe(By.className("attender-row-div"), 2), "Unexpected number of attenders for the course"); - teacher.getDriver().findElement(By.cssSelector("app-error-message .card-panel.correct .material-icons")).click(); + user.getDriver().findElement(By.cssSelector("app-error-message .card-panel.correct .material-icons")).click(); log.info("Attender addition successfully finished"); // Remove attender log.info("Removing attender"); - teacher.getDriver().findElement(By.id("edit-attenders-icon")).click(); - teacher.waitUntil(ExpectedConditions.elementToBeClickable(By.cssSelector(".del-attender-icon")), + user.getDriver().findElement(By.id("edit-attenders-icon")).click(); + user.waitUntil(ExpectedConditions.elementToBeClickable(By.cssSelector(".del-attender-icon")), "Button for attender deletion not clickable"); - teacher.getDriver().findElement(By.cssSelector(".del-attender-icon")).click(); - teacher.waitUntil(ExpectedConditions.numberOfElementsToBe(By.className("attender-row-div"), 1), + user.getDriver().findElement(By.cssSelector(".del-attender-icon")).click(); + user.waitUntil(ExpectedConditions.numberOfElementsToBe(By.className("attender-row-div"), 1), "Unexpected number of attenders for the course"); log.info("Attender successfully removed"); - CourseNavigationUtilities.deleteCourse(teacher.getDriver(), COURSE_NAME); + CourseNavigationUtilities.deleteCourse(user.getDriver(), COURSE_NAME); } /*** Auxiliary methods ***/ @@ -451,8 +451,8 @@ void attendersRestOperations(String mail, String password, String role) throws E private void enterCourseAndNavigateTab(String courseName, String tabId) { //16 lines log.info("Entering course {}", courseName); //All these tests always create a new course, so we wait for 3-courses in the main page (more than 2) - teacher.waitUntil(ExpectedConditions.numberOfElementsToBeMoreThan(By.cssSelector("#course-list .course-list-item div.course-title span"), 2), "The number of courses should be 3"); - List allCourses = teacher.getDriver() + user.waitUntil(ExpectedConditions.numberOfElementsToBeMoreThan(By.cssSelector("#course-list .course-list-item div.course-title span"), 2), "The number of courses should be 3"); + List allCourses = user.getDriver() .findElements(By.cssSelector("#course-list .course-list-item div.course-title span")); WebElement courseSpan = null; for (WebElement c : allCourses) { @@ -464,9 +464,9 @@ private void enterCourseAndNavigateTab(String courseName, String tabId) { //16 l assertNotNull(courseSpan, "The course with the name '" + courseName + "' could not be found. Total courses available: " + allCourses.size()); courseSpan.click(); - teacher.waitUntil(ExpectedConditions.textToBe(By.id("main-course-title"), courseName), "Unexpected course title"); + user.waitUntil(ExpectedConditions.textToBe(By.id("main-course-title"), courseName), "Unexpected course title"); log.info("Navigating to tab by clicking icon with id '{}'", tabId); - teacher.getDriver().findElement(By.id(tabId)).click(); + user.getDriver().findElement(By.id(tabId)).click(); } diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingLoggedVideoSessionTests.java b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingLoggedVideoSessionTests.java index 5f4f038..b7f6bf1 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingLoggedVideoSessionTests.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingLoggedVideoSessionTests.java @@ -23,6 +23,7 @@ import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Calendar; import java.util.List; @@ -62,16 +63,16 @@ public static Stream data() throws IOException { @DisplayName("sessionTest") @ParameterizedTest @MethodSource("data") - void sessionTest(String mail, String password, String role) throws ElementNotFoundException, IOException { + void sessionTest(String mail, String password, String role) throws ElementNotFoundException, IOException, URISyntaxException { String sessionName = "Today's Session"; courseName = "Pseudoscientific course for treating the evil eye"; - this.slowLogin(this.teacher, mail, password); + this.slowLogin(this.user, mail, password); initializeStudents("src/test/resources/inputs/default_user_LoggedVideoStudents.csv"); createNewSession(sessionName); - joinSession(sessionName, this.teacher); + joinSession(sessionName, this.user); joinSessionStudents(sessionName); leaveStudentSessions(); - leaveSession(this.teacher); + leaveSession(this.user); deleteSession(sessionName); } @@ -80,7 +81,7 @@ void sessionTest(String mail, String password, String role) throws ElementNotFou * @param pathData the path to the CSV file containing student data * @throws IOException if there is an error reading the file */ - private void initializeStudents(String pathData) throws IOException { + private void initializeStudents(String pathData) throws IOException, URISyntaxException { log.info("Initializing students"); String users_data = loadStudentsData(pathData); studentNameList = new ArrayList<>(); @@ -113,19 +114,19 @@ private void createNewSession(String sessionName) throws ElementNotFoundExceptio String sessionHour = getCurrentTime(); String sessionDescription = "Wow today session will be amazing"; - navigateToCourse(teacher, courseName); - Click.element(teacher.getDriver(), SESSION_LIST_NEW_SESSION_ICON); - WebElement modal = Wait.notTooMuch(teacher.getDriver()).until(ExpectedConditions.visibilityOfElementLocated(SESSION_LIST_NEW_SESSION_MODAL)); + navigateToCourse(user, courseName); + Click.element(user.getDriver(), SESSION_LIST_NEW_SESSION_ICON); + WebElement modal = Wait.notTooMuch(user.getDriver()).until(ExpectedConditions.visibilityOfElementLocated(SESSION_LIST_NEW_SESSION_MODAL)); modal.findElement(SESSION_LIST_NEW_SESSION_MODAL_TITLE).sendKeys(sessionName); modal.findElement(SESSION_LIST_NEW_SESSION_MODAL_CONTENT).sendKeys(sessionDescription); modal.findElement(SESSION_LIST_NEW_SESSION_MODAL_DATE).sendKeys(sessionDate); modal.findElement(SESSION_LIST_NEW_SESSION_MODAL_TIME).sendKeys(sessionHour); - Click.element(teacher.getDriver(), modal.findElement(SESSION_LIST_NEW_SESSION_MODAL_POST_BUTTON)); - Wait.notTooMuch(teacher.getDriver()); + Click.element(user.getDriver(), modal.findElement(SESSION_LIST_NEW_SESSION_MODAL_POST_BUTTON)); + Wait.notTooMuch(user.getDriver()); // Verify session creation - Wait.waitForPageLoaded(teacher.getDriver()); - teacher.waitUntil(ExpectedConditions.numberOfElementsToBeMoreThan(SESSION_LIST_SESSION_ROW,3),"Incorrect number of sessions (never more than 2)"); - List session_titles = SessionNavigationUtilities.getFullSessionList(teacher.getDriver()); + Wait.waitForPageLoaded(user.getDriver()); + user.waitUntil(ExpectedConditions.numberOfElementsToBeMoreThan(SESSION_LIST_SESSION_ROW,3),"Incorrect number of sessions (never more than 2)"); + List session_titles = SessionNavigationUtilities.getFullSessionList(user.getDriver()); assertTrue(session_titles.contains(sessionName), "Session has not been created"); } /** @@ -209,13 +210,13 @@ private void deleteSession(String sessionName) throws ElementNotFoundException { List session_titles; WebElement modal; WebElement session; - session = SessionNavigationUtilities.getSession(teacher.getDriver(), sessionName); - Click.element(teacher.getDriver(), session.findElement(SESSION_LIST_SESSION_EDIT_ICON)); - modal = Wait.notTooMuch(teacher.getDriver()).until(ExpectedConditions.visibilityOfElementLocated(SESSION_LIST_EDIT_MODAL)); - Click.element(teacher.getDriver(), modal.findElement(SESSION_LIST_EDIT_MODAL_DELETE_DIV).findElement(By.tagName("label"))); - Click.element(teacher.getDriver(), modal.findElement(SESSION_LIST_EDIT_MODAL_DELETE_DIV).findElement(By.tagName("a"))); - Wait.waitForPageLoaded(teacher.getDriver());//13 lines - session_titles = SessionNavigationUtilities.getFullSessionList(teacher.getDriver()); //7 lines + session = SessionNavigationUtilities.getSession(user.getDriver(), sessionName); + Click.element(user.getDriver(), session.findElement(SESSION_LIST_SESSION_EDIT_ICON)); + modal = Wait.notTooMuch(user.getDriver()).until(ExpectedConditions.visibilityOfElementLocated(SESSION_LIST_EDIT_MODAL)); + Click.element(user.getDriver(), modal.findElement(SESSION_LIST_EDIT_MODAL_DELETE_DIV).findElement(By.tagName("label"))); + Click.element(user.getDriver(), modal.findElement(SESSION_LIST_EDIT_MODAL_DELETE_DIV).findElement(By.tagName("a"))); + Wait.waitForPageLoaded(user.getDriver());//13 lines + session_titles = SessionNavigationUtilities.getFullSessionList(user.getDriver()); //7 lines assertFalse(session_titles.contains(sessionName), "Session has not been deleted"); } diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingTestEndToEndVideoSessionTests.java b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingTestEndToEndVideoSessionTests.java index 51690ac..5f660d2 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingTestEndToEndVideoSessionTests.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingTestEndToEndVideoSessionTests.java @@ -31,6 +31,8 @@ import org.openqa.selenium.support.ui.ExpectedConditions; import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URISyntaxException; import java.util.stream.Stream; @@ -62,36 +64,36 @@ public FullTeachingTestEndToEndVideoSessionTests() { @DisplayName("sessionTest") @ParameterizedTest @MethodSource("data") - void oneToOneVideoAudioSessionChrome(String mail, String password, String role) { //124+ 232+ 20 set up +8 lines teardown = 564 + void oneToOneVideoAudioSessionChrome(String mail, String password, String role) throws URISyntaxException, MalformedURLException { //124+ 232+ 20 set up +8 lines teardown = 564 // TEACHER - this.slowLogin(teacher, mail, password);//24 + this.slowLogin(user, mail, password);//24 - log.info("{} entering first course", teacher.getClientData()); - teacher.getWaiter().until( + log.info("{} entering first course", user.getClientData()); + user.getWaiter().until( ExpectedConditions.presenceOfElementLocated(By.cssSelector( ("ul.collection li.collection-item:first-child div.course-title")))); - teacher.getDriver().findElement(By.cssSelector( + user.getDriver().findElement(By.cssSelector( "ul.collection li.collection-item:first-child div.course-title")) .click(); - log.info("{} navigating to 'Sessions' tab", teacher.getClientData()); - teacher.getWaiter().until(ExpectedConditions.presenceOfElementLocated( + log.info("{} navigating to 'Sessions' tab", user.getClientData()); + user.getWaiter().until(ExpectedConditions.presenceOfElementLocated( By.cssSelector(("#md-tab-label-0-1")))); - teacher.getDriver().findElement(By.cssSelector("#md-tab-label-0-1")) + user.getDriver().findElement(By.cssSelector("#md-tab-label-0-1")) .click(); - log.info("{} getting into first session", teacher.getClientData()); - teacher.getDriver() + log.info("{} getting into first session", user.getClientData()); + user.getDriver() .findElement(By.cssSelector( "ul div:first-child li.session-data div.session-ready")) .click(); - teacher.getWaiter().until(ExpectedConditions.presenceOfElementLocated( + user.getWaiter().until(ExpectedConditions.presenceOfElementLocated( By.cssSelector(("div.participant video")))); - checkVideoPlaying(teacher, - teacher.getDriver() + checkVideoPlaying(user, + user.getDriver() .findElement(By.cssSelector(("div.participant video"))), "div.participant"); //30 lines // STUDENT @@ -132,10 +134,10 @@ void oneToOneVideoAudioSessionChrome(String mail, String password, String role) .click(); // Teacher accepts intervention - teacher.getWaiter().until(ExpectedConditions.elementToBeClickable( + user.getWaiter().until(ExpectedConditions.elementToBeClickable( By.xpath("//a[contains(@class, 'usr-btn')]"))); - log.info("{} accepts student intervention", teacher.getClientData()); - teacher.getDriver() + log.info("{} accepts student intervention", user.getClientData()); + user.getDriver() .findElement(By.xpath("//a[contains(@class, 'usr-btn')]")) .click(); // Check both videos for both users @@ -151,27 +153,27 @@ void oneToOneVideoAudioSessionChrome(String mail, String password, String role) student.getDriver() .findElement(By.cssSelector(("div.participant video"))), "div.participant");//30 lines - teacher.getWaiter().until(ExpectedConditions.presenceOfElementLocated( + user.getWaiter().until(ExpectedConditions.presenceOfElementLocated( By.cssSelector(("div.participant-small video")))); // Small video of teacher - checkVideoPlaying(teacher, - teacher.getDriver().findElement( + checkVideoPlaying(user, + user.getDriver().findElement( By.cssSelector(("div.participant-small video"))), "div.participant-small");//30 lines // Main video of teacher - checkVideoPlaying(teacher, - teacher.getDriver() + checkVideoPlaying(user, + user.getDriver() .findElement(By.cssSelector(("div.participant video"))), "div.participant"); // Teacher stops student intervention - teacher.getWaiter().until(ExpectedConditions.elementToBeClickable( + user.getWaiter().until(ExpectedConditions.elementToBeClickable( By.xpath("//a[contains(@class, 'usr-btn')]"))); - log.info("{} canceling student intervention", teacher.getClientData()); - teacher.getDriver() + log.info("{} canceling student intervention", user.getClientData()); + user.getDriver() .findElement(By.xpath("//a[contains(@class, 'usr-btn')]")) .click(); // Wait until only one video - teacher.getWaiter().until(ExpectedConditions + user.getWaiter().until(ExpectedConditions .not(ExpectedConditions.presenceOfAllElementsLocatedBy( By.cssSelector(("div.participant-small video"))))); student.getWaiter().until(ExpectedConditions diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/student/CourseStudentTest.java b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/student/CourseStudentTest.java index 12100a9..126141e 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/student/CourseStudentTest.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/student/CourseStudentTest.java @@ -48,7 +48,7 @@ public static Stream data() throws IOException { @ParameterizedTest @MethodSource("data") void studentCourseMainTest(String userMail, String password, String role) {//45+ 107+28 set up +13 lines teardown =193 - this.slowLogin(teacher, userMail, password);//24 lines + this.slowLogin(user, userMail, password);//24 lines try { NavigationUtilities.toCoursesHome(driver); //3lines //go to first course diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/teacher/CourseTeacherTest.java b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/teacher/CourseTeacherTest.java index dfd0cc4..6a40448 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/teacher/CourseTeacherTest.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/teacher/CourseTeacherTest.java @@ -50,7 +50,7 @@ public static Stream data() throws IOException { @ParameterizedTest @MethodSource("data") void teacherCourseMainTest(String mail, String password, String role) {//39+80+ 28 set up +13 lines teardown =160 - this.slowLogin(teacher, mail, password); + this.slowLogin(user, mail, password); try { NavigationUtilities.toCoursesHome(driver); //4lines @@ -106,23 +106,23 @@ void teacherCourseMainTest(String mail, String password, String role) {//39+80+ @MethodSource("data") void teacherCreateAndDeleteCourseTest(String mail, String password, String role) throws ElementNotFoundException { // Setup - this.slowLogin(teacher, mail, password); + this.slowLogin(user, mail, password); // Create a new course String courseTitle = "Test Course_" + System.currentTimeMillis(); - CourseNavigationUtilities.newCourse(teacher.getDriver(), courseTitle); + CourseNavigationUtilities.newCourse(user.getDriver(), courseTitle); //TO-DO the problem its here // Verify the course has been created assertTrue(checkIfCourseExists(driver, courseTitle)); // Delete the course - CourseNavigationUtilities.deleteCourse(teacher.getDriver(), courseTitle); + CourseNavigationUtilities.deleteCourse(user.getDriver(), courseTitle); // Verify the course has been deleted assertFalse(checkIfCourseExists(driver, courseTitle)); // Teardown - teacher.getDriver().get(APP_URL); + user.getDriver().get(APP_URL); } @@ -146,7 +146,7 @@ void teacherCreateAndDeleteCourseTest(String mail, String password, String role) @MethodSource("data") void teacherEditCourseValues(String mail, String password, String role) {//165+256+ 28 set up +13 lines teardown =462 String courseName = properties.getProperty("forum.test.course"); - this.slowLogin(teacher, mail, password); //24 lines + this.slowLogin(user, mail, password); //24 lines try { // navigate to course if not there NavigationUtilities.toCoursesHome(driver);//3lines @@ -213,7 +213,7 @@ void teacherEditCourseValues(String mail, String password, String role) {//165+2 editor = driver.findElement(By.className("ql-editor")); jse.executeScript("arguments[0].innerHTML = '

New Title

New SubHeading

This is the normal content

'", editor); driver.findElement(By.xpath("//*[@id=\"textEditorRowButtons\"]/a[2]")).click(); - teacher.waitUntil(ExpectedConditions.visibilityOfElementLocated(By.className("ql-editor-custom")), "Element that was waiting doesn't found"); + user.waitUntil(ExpectedConditions.visibilityOfElementLocated(By.className("ql-editor-custom")), "Element that was waiting doesn't found"); WebElement preview = Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.className("ql-editor-custom"))); //check heading TO-DO : Error here, the type of font is not saved assertEquals("New Title", preview.findElement(By.tagName("h1")).getText(), "Heading preview not properly rendered"); @@ -309,7 +309,7 @@ void teacherEditCourseValues(String mail, String password, String role) {//165+2 @ParameterizedTest @MethodSource("data") void teacherDeleteCourseTest(String mail, String password, String role) throws ElementNotFoundException {//51+114+28 set up +13 lines teardown =206 - this.slowLogin(teacher, mail, password);//24 + this.slowLogin(user, mail, password);//24 String courseName = "Test Course_" + System.currentTimeMillis(); // navigate to course if not there try { @@ -332,9 +332,9 @@ void teacherDeleteCourseTest(String mail, String password, String role) throws E // in attenders // TODO: add attenders // delete course - List allCoursesPriorDeleting = teacher.getDriver().findElements(By.className("course-list-item")); - CourseNavigationUtilities.deleteCourse(teacher.getDriver(), courseName); - List allCourses = teacher.getDriver().findElements(By.className("course-list-item")); + List allCoursesPriorDeleting = user.getDriver().findElements(By.className("course-list-item")); + CourseNavigationUtilities.deleteCourse(user.getDriver(), courseName); + List allCourses = user.getDriver().findElements(By.className("course-list-item")); assertEquals(allCoursesPriorDeleting.size() - 1, allCourses.size()); //Well done! }