Skip to content

Commit aef764f

Browse files
author
Matécsa Dániel
committed
Url array test added
1 parent b7b7cbe commit aef764f

5 files changed

Lines changed: 49 additions & 6 deletions

File tree

points.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ basic:
6363
description: "Log out from the application and verify it"
6464

6565
fill_input: # 1 pt each | repeatable | max 10
66-
count: 2
66+
count: 3
6767
description: "Fill an input field (text, radio, checkbox, date, etc.) — each different type counts as one"
6868

6969
send_form: # 1 pt each | repeatable | max 10
@@ -75,7 +75,7 @@ basic:
7575
description: "Test a static page (verify text content, element presence, etc.)"
7676

7777
multiple_page_test: # 3 pts | once
78-
done: false
78+
done: true
7979
description: "Define an array of URLs or page data, iterate over them and verify something on each page (e.g. check title or a specific element on 5 different pages using a loop)"
8080

8181
complex_xpath: # 1 pt each | repeatable | max 10
@@ -87,7 +87,7 @@ basic:
8787
description: "Fill or read the content of a textarea element"
8888

8989
dropdown: # 2 pts | once
90-
done: false
90+
done: true
9191
description: "Select an option from a drop-down (using Select class or similar)"
9292
link: "https://www.selenium.dev/documentation/webdriver/support_features/select_lists/"
9393

tests/mytests/settings.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
selenium_url: "http://selenium:4444/wd/hub"
22
moodle_url: "https://elteseleniumtesting.moodlecloud.com/login/index.php"
33
login_username: "elte.selenium.moodle@gmail.com"
4-
login_password: "Elte_selenium_moodle191"
4+
login_password: "Elte_selenium_moodle191"
5+
array_of_urls:
6+
- "https://elteseleniumtesting.moodlecloud.com/my/"
7+
- "https://elteseleniumtesting.moodlecloud.com/my/courses.php"
8+
- "https://elteseleniumtesting.moodlecloud.com/course/edit.php?category=1"
9+
- "https://elteseleniumtesting.moodlecloud.com/course/view.php?id=9"
10+
array_of_urls_contents:
11+
- "Dashboard"
12+
- "Course overview"
13+
- "Add a new course"
14+
- "Test Course 1 Manual"

tests/mytests/src/test/java/pages/CourseCreatorPage.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class CourseCreatorPage extends PageBase {
1010
private By visibilitySelect = By.cssSelector("#id_visible");
1111
//private By hoverable = By.cssSelector("#fitem_id_fullname > div.col-md-3.col-form-label.d-flex.pb-0.pe-md-0 > div > a > i");
1212
private By createCourseButton = By.cssSelector("#id_saveanddisplay");
13+
private By endDateEnabledCheckbox = By.cssSelector("#id_enddate_enabled");
1314

1415
public CourseCreatorPage(WebDriver driver)
1516
{
@@ -36,6 +37,12 @@ public List<WebElement> selectCourseVisibility(int index) {
3637
return select.getOptions();
3738
}
3839

40+
public WebElement clickEndDateEnabledCheckbox() {
41+
WebElement checkbox = waitAndReturnElement(endDateEnabledCheckbox);
42+
checkbox.click();
43+
return checkbox;
44+
}
45+
3946
public CoursePage submitCreateCourse() {
4047
WebElement createCourseBtn = waitAndReturnElement(createCourseButton);
4148
createCourseBtn.submit();

tests/mytests/src/test/java/tests/WebsiteTest.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.testng.*;
1111

1212
import pages.*;
13+
import utils.ConfigReader;
1314

1415
public class WebsiteTest extends TestBase {
1516

@@ -20,7 +21,7 @@ public void Setup() throws MalformedURLException
2021
}
2122

2223
@Test
23-
public void courseCreation() {
24+
public void courseCreationTest() {
2425
LoginPage loginPage = null;
2526

2627
loginPage = login(loginPage);
@@ -42,6 +43,9 @@ public void courseCreation() {
4243
Assert.assertTrue(selectElements.get(1).isSelected());
4344
Assert.assertFalse(selectElements.get(0).isSelected());
4445

46+
WebElement checkboxElement = courseCreatorPage.clickEndDateEnabledCheckbox();
47+
Assert.assertFalse(checkboxElement.isSelected());
48+
4549
CoursePage coursePage = courseCreatorPage.submitCreateCourse();
4650
Assert.assertTrue(coursePage.getBodyText().contains("Selenium Testing Course " + randomNum));
4751

@@ -51,7 +55,7 @@ public void courseCreation() {
5155
}
5256

5357
@Test
54-
public void cookieHandling() {
58+
public void cookieHandlingTest() {
5559
LoginPage loginPage = null;
5660

5761
loginPage = login(loginPage);
@@ -82,6 +86,23 @@ public void cookieHandling() {
8286
System.out.println("Cookie handling test completed.");
8387
}
8488

89+
@Test
90+
public void arrayofUrlsTest() {
91+
LoginPage loginPage = null;
92+
loginPage = login(loginPage);
93+
loginPage.clickLogin();
94+
List<String> urls = ConfigReader.getList("array_of_urls");
95+
List<String> urlContents = ConfigReader.getList("array_of_urls_contents");
96+
for (int i = 0; i < urls.size(); i++) {
97+
String url = urls.get(i);
98+
driver.navigate().to(url);
99+
PageBase page = new PageBase(driver);
100+
Assert.assertTrue(page.getBodyText().contains(urlContents.get(i)));
101+
}
102+
103+
System.out.println("Array of URLs test completed.");
104+
}
105+
85106

86107
@AfterMethod
87108
public void close() {

tests/mytests/src/test/java/utils/ConfigReader.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.File;
55
import java.io.FileInputStream;
66
import java.io.InputStream;
7+
import java.util.List;
78
import java.util.Map;
89

910
public class ConfigReader {
@@ -31,4 +32,8 @@ public class ConfigReader {
3132
public static String get(String key) {
3233
return (String) settings.get(key);
3334
}
35+
36+
public static List<String> getList(String key) {
37+
return (List<String>) settings.get(key);
38+
}
3439
}

0 commit comments

Comments
 (0)