From fa9c17c036207b35a489359bec865c3065e6aaad Mon Sep 17 00:00:00 2001 From: 0nlineSam Date: Thu, 30 Jan 2025 14:24:56 +0100 Subject: [PATCH] Initial solution for task 1 --- Homework12/.gitignore | 38 +++++++++++ Homework12/.idea/.gitignore | 8 +++ Homework12/.idea/encodings.xml | 7 ++ Homework12/.idea/misc.xml | 14 ++++ Homework12/.idea/vcs.xml | 6 ++ Homework12/pom.xml | 29 ++++++++ .../src/main/java/org/example/Main.java | 7 ++ Homework12/src/test/java/Ueb12Test.java | 67 +++++++++++++++++++ 8 files changed, 176 insertions(+) create mode 100644 Homework12/.gitignore create mode 100644 Homework12/.idea/.gitignore create mode 100644 Homework12/.idea/encodings.xml create mode 100644 Homework12/.idea/misc.xml create mode 100644 Homework12/.idea/vcs.xml create mode 100644 Homework12/pom.xml create mode 100644 Homework12/src/main/java/org/example/Main.java create mode 100644 Homework12/src/test/java/Ueb12Test.java diff --git a/Homework12/.gitignore b/Homework12/.gitignore new file mode 100644 index 00000000..5ff6309b --- /dev/null +++ b/Homework12/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/Homework12/.idea/.gitignore b/Homework12/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/Homework12/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/Homework12/.idea/encodings.xml b/Homework12/.idea/encodings.xml new file mode 100644 index 00000000..aa00ffab --- /dev/null +++ b/Homework12/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Homework12/.idea/misc.xml b/Homework12/.idea/misc.xml new file mode 100644 index 00000000..d1bcac9c --- /dev/null +++ b/Homework12/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Homework12/.idea/vcs.xml b/Homework12/.idea/vcs.xml new file mode 100644 index 00000000..6c0b8635 --- /dev/null +++ b/Homework12/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Homework12/pom.xml b/Homework12/pom.xml new file mode 100644 index 00000000..85b42208 --- /dev/null +++ b/Homework12/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + org.example + Homework12 + 1.0-SNAPSHOT + + + 23 + 23 + UTF-8 + + + + org.junit.jupiter + junit-jupiter + 5.11.4 + + + org.seleniumhq.selenium + selenium-java + 4.28.1 + + + + \ No newline at end of file diff --git a/Homework12/src/main/java/org/example/Main.java b/Homework12/src/main/java/org/example/Main.java new file mode 100644 index 00000000..0c1e8ee8 --- /dev/null +++ b/Homework12/src/main/java/org/example/Main.java @@ -0,0 +1,7 @@ +package org.example; + +public class Main { + public static void main(String[] args) { + System.out.println("Hello, World!"); + } +} \ No newline at end of file diff --git a/Homework12/src/test/java/Ueb12Test.java b/Homework12/src/test/java/Ueb12Test.java new file mode 100644 index 00000000..a5544edb --- /dev/null +++ b/Homework12/src/test/java/Ueb12Test.java @@ -0,0 +1,67 @@ +// Generated by Selenium IDE + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.*; +import org.openqa.selenium.firefox.FirefoxDriver; + +import java.time.Duration; +import java.util.*; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class Ueb12Test { + private WebDriver driver; + private Map vars; + JavascriptExecutor js; + @BeforeEach + public void setUp() { + driver = new FirefoxDriver(); + js = (JavascriptExecutor) driver; + vars = new HashMap<>(); + } + @AfterEach + public void tearDown() { + driver.quit(); + } + + @Test + public void ueb12() { + driver.get("https://duckduckgo.com/"); + driver.manage().window().setSize(new Dimension(601, 683)); + driver.findElement(By.id("searchbox_input")).sendKeys("uni marburg fb 12"); + driver.findElement(By.cssSelector(".iconButton_size-20__O3lP5")).click(); + driver.findElement(By.xpath("//span[contains(.,\'Philipps-Universität Marburg - Mathematik und Informatik\')]")).click(); + + //driver.get("https://www.uni-marburg.de/de/fb12"); + + //driver.findElement(By.id("APjFqb")).sendKeys("fb12 uni marburg"); + //driver.findElement(By.name("btnK")).click(); + //driver.findElement(By.xpath("//h3[contains(.,\'Mathematik und Informatik\')]")).click(); + vars.put("buttonText", driver.findElement(By.cssSelector(".language > a")).getText()); + if ((Boolean) js.executeScript("return (arguments[0] == \'ENGLISH\')", vars.get("buttonText"))) { + driver.findElement(By.cssSelector(".language > a")).click(); + } + assertEquals("Department", driver.findElement(By.linkText("Department")).getText()); + assertEquals("Studying", driver.findElement(By.linkText("Studying")).getText()); + assertEquals("Research", driver.findElement(By.linkText("Research")).getText()); + assertEquals("Research groups", driver.findElement(By.linkText("Research groups")).getText()); + driver.findElement(By.cssSelector("ul:nth-child(2) > .has-children:nth-child(3) > a")).click(); + assertEquals("Modules & Courses\nModules and Courses", driver.findElement(By.cssSelector("li:nth-child(4) > a > div")).getText()); + driver.findElement(By.cssSelector("li:nth-child(4) > a > div")).click(); + driver.findElement(By.cssSelector(".link-text-list:nth-child(6) .diazoadded")).click(); + vars.put("buttonText", driver.findElement(By.cssSelector(".language > a")).getText()); + if ((Boolean) js.executeScript("return (arguments[0] == \'ENGLISH\')", vars.get("buttonText"))) { + driver.findElement(By.cssSelector(".language > a")).click(); + } + driver.findElement(By.cssSelector("ul > ul:nth-child(1) > li:nth-child(7) > a")).click(); + driver.findElement(By.linkText("Alphabetical index of all modules in this course")).click(); + driver.findElement(By.linkText("Software Quality")).click(); + driver.findElement(By.cssSelector(".cols1")).click(); + assertEquals("CS 661 — Software Quality", driver.findElement(By.cssSelector("h1 > b")).getText()); + assertEquals("Lecture (4 SWS), recitation class (2 SWS),\n270 hours (90 h attendance, 180 h private study)", driver.findElement(By.cssSelector("tr:nth-child(2) > td:nth-child(2)")).getText()); + assertEquals("Lecture (4 SWS), recitation class (2 SWS),\n270 hours (90 h attendance, 180 h private study)", driver.findElement(By.cssSelector("tr:nth-child(2) > td:nth-child(2)")).getText()); + assertEquals("9 CP\nCourse requirement(s): Successful completion of at least 50 percent of the points from the weekly exercises as well as at least 2 presentations of the tasks.\nExamination type: Oral examination (individual examination) or written examination", driver.findElement(By.cssSelector("tr:nth-child(3) > td:nth-child(2)")).getText()); + } +}