-
Notifications
You must be signed in to change notification settings - Fork 20
Hotove testy z kurzu automatizace #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,193 @@ | ||||||||||||||||||||||||||||||||
| package cz.czechitas.automation; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| import org.junit.jupiter.api.Test; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| final class MyFirstTest extends TestRunner { | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| private void login() { | ||||||||||||||||||||||||||||||||
| browser.loginSection.clickLoginMenuLink(); | ||||||||||||||||||||||||||||||||
| browser.loginSection.insertEmail("manka.rumova@yahoo.com"); | ||||||||||||||||||||||||||||||||
| browser.loginSection.insertPassword("Hovinko123"); | ||||||||||||||||||||||||||||||||
| browser.loginSection.clickLoginButton(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||
| void navigateToParentInstructionsAndFormsTest() { | ||||||||||||||||||||||||||||||||
| browser.headerMenu.goToInstructionsAndFormsForParentSection(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||
| void orderSuburbanCampTest() { | ||||||||||||||||||||||||||||||||
| browser.headerMenu.goToKindergartenAndSchoolSection(); | ||||||||||||||||||||||||||||||||
| browser.orderSection.selectSuburbanCampOption(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||
| void navigateAllMenuSectionsTest() { | ||||||||||||||||||||||||||||||||
| browser.headerMenu.goToHomePage(); | ||||||||||||||||||||||||||||||||
| browser.headerMenu.goToContactsSection(); | ||||||||||||||||||||||||||||||||
| browser.headerMenu.goToInstructionsAndFormsForParentSection(); | ||||||||||||||||||||||||||||||||
| browser.headerMenu.goToCreateApplicationSection(); | ||||||||||||||||||||||||||||||||
| browser.headerMenu.goToInstructionsAndFormsForTeacherSection(); | ||||||||||||||||||||||||||||||||
| browser.headerMenu.goToKindergartenAndSchoolSection(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||
| void fillICOTest() { | ||||||||||||||||||||||||||||||||
| browser.headerMenu.goToKindergartenAndSchoolSection(); | ||||||||||||||||||||||||||||||||
| browser.orderSection.insertICO("22834958"); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||
| void createApplicationTest() { | ||||||||||||||||||||||||||||||||
| browser.loginSection.clickLoginMenuLink(); | ||||||||||||||||||||||||||||||||
| browser.loginSection.insertEmail("manka.rumova@yahoo.com"); | ||||||||||||||||||||||||||||||||
| browser.loginSection.insertPassword("Hovinko123"); | ||||||||||||||||||||||||||||||||
| browser.loginSection.clickLoginButton(); | ||||||||||||||||||||||||||||||||
| browser.applicationSection.clickCreateNewApplicationButton(); | ||||||||||||||||||||||||||||||||
| browser.applicationSection.selectProgrammingSection(); | ||||||||||||||||||||||||||||||||
| browser.applicationSection.clickCreatePythonApplicationButton(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+38
to
+46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win Use the Lines 39-42 duplicate the login logic that's already extracted in the ♻️ Suggested refactor `@Test`
void createApplicationTest() {
- browser.loginSection.clickLoginMenuLink();
- browser.loginSection.insertEmail("manka.rumova@yahoo.com");
- browser.loginSection.insertPassword("Hovinko123");
- browser.loginSection.clickLoginButton();
+ login();
browser.applicationSection.clickCreateNewApplicationButton();
browser.applicationSection.selectProgrammingSection();
browser.applicationSection.clickCreatePythonApplicationButton();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||
| void checkProgrammingTileTest() { | ||||||||||||||||||||||||||||||||
| asserter.checkProgrammingSectionPresence(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||
| void checkRegistrationButtonTest() { | ||||||||||||||||||||||||||||||||
| browser.headerMenu.goToCreateApplicationSection(); | ||||||||||||||||||||||||||||||||
| asserter.checkRegistrationButtonPresence(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||
| void checkPaymentMethodTest() { | ||||||||||||||||||||||||||||||||
| login(); | ||||||||||||||||||||||||||||||||
| browser.applicationSection.openFirstApplicationDetailsPage(); | ||||||||||||||||||||||||||||||||
| asserter.applicationDetailSection.checkPaymentMethod("Bankovní převod"); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||
| void orderWithICOAndSchoolInNatureTest() { | ||||||||||||||||||||||||||||||||
| browser.headerMenu.goToKindergartenAndSchoolSection(); | ||||||||||||||||||||||||||||||||
| asserter.checkPageUrl("www.czechitas.cz"); | ||||||||||||||||||||||||||||||||
| browser.orderSection.insertICO("22834958"); | ||||||||||||||||||||||||||||||||
| asserter.orderSection.checkIcoFieldContainsValue("22834958"); | ||||||||||||||||||||||||||||||||
| browser.orderSection.selectSchoolInNatureOption(); | ||||||||||||||||||||||||||||||||
| browser.orderSection.insertChildrenCount(15); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||
| void checkApplicationColumnsTest() { | ||||||||||||||||||||||||||||||||
| login(); | ||||||||||||||||||||||||||||||||
| browser.headerMenu.goToApplicationsSection(); | ||||||||||||||||||||||||||||||||
| asserter.applicationSection.checkColumnExists("Jméno", "Kategorie"); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||
| void complexApplicationTest() { | ||||||||||||||||||||||||||||||||
| login(); | ||||||||||||||||||||||||||||||||
| browser.headerMenu.goToApplicationsSection(); | ||||||||||||||||||||||||||||||||
| browser.applicationSection.clickCreateNewApplicationButton(); | ||||||||||||||||||||||||||||||||
| browser.applicationSection.selectProgrammingSection(); | ||||||||||||||||||||||||||||||||
| browser.applicationSection.clickCreatePythonApplicationButton(); | ||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.selectTerm("08.06. - 19.06.2026"); | ||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.insertStudentFirstName("Jan"); | ||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.insertStudentLastName("Testovaci"); | ||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.insertBirthdate("01.01.2015"); | ||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.insertNote("Testovaci poznamka"); | ||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.selectCashPaymentMethod(); | ||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.clickAcceptTermsCheckbox(); | ||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.clickCreateApplicationButton(); | ||||||||||||||||||||||||||||||||
| asserter.applicationDetailSection.checkTerm("08.06. - 19.06.2026"); | ||||||||||||||||||||||||||||||||
| asserter.applicationDetailSection.checkFirstName("Jan"); | ||||||||||||||||||||||||||||||||
| asserter.applicationDetailSection.checkLastName("Testovaci"); | ||||||||||||||||||||||||||||||||
| asserter.applicationDetailSection.checkDateOfBirth("01.01.2015"); | ||||||||||||||||||||||||||||||||
| asserter.applicationDetailSection.checkNote("Testovaci poznamka"); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||
| void searchAndEditApplicationTest() { | ||||||||||||||||||||||||||||||||
| login(); | ||||||||||||||||||||||||||||||||
| browser.headerMenu.goToApplicationsSection(); | ||||||||||||||||||||||||||||||||
| browser.applicationSection.search("Tester001"); | ||||||||||||||||||||||||||||||||
| browser.applicationSection.clickEditFirstApplicationButton(); | ||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.selectBankTransferPaymentMethod(); | ||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.clickEditApplicationButton(); | ||||||||||||||||||||||||||||||||
| browser.applicationSection.search("Tester001"); | ||||||||||||||||||||||||||||||||
| browser.applicationSection.openFirstApplicationDetailsPage(); | ||||||||||||||||||||||||||||||||
| asserter.applicationDetailSection.checkPaymentMethod("Bankovní převod"); | ||||||||||||||||||||||||||||||||
| asserter.applicationDetailSection.checkRemainingAmountToPay("2 490 Kč"); | ||||||||||||||||||||||||||||||||
| asserter.applicationDetailSection.checkMessageContainsStudentLastName("Tester001"); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||
| void twoUsersApplicationTest() { | ||||||||||||||||||||||||||||||||
| // Prihlaseni jako prvni uzivatel | ||||||||||||||||||||||||||||||||
| login(); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Vygenerovani nahodneho jmena a ulozeni do pormenne | ||||||||||||||||||||||||||||||||
| var randomPrijmeni = browser.generateRandomName(10); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Vytvoreni prihlasky | ||||||||||||||||||||||||||||||||
| browser.headerMenu.goToApplicationsSection(); | ||||||||||||||||||||||||||||||||
| browser.applicationSection.clickCreateNewApplicationButton(); | ||||||||||||||||||||||||||||||||
| browser.applicationSection.selectProgrammingSection(); | ||||||||||||||||||||||||||||||||
| browser.applicationSection.clickCreatePythonApplicationButton(); | ||||||||||||||||||||||||||||||||
| browser.waitFor(3); | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace hard wait with explicit wait. The 3-second 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.selectTerm("08.06. - 19.06.2026"); | ||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.insertStudentFirstName("Test"); | ||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.insertStudentLastName(randomPrijmeni); | ||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.insertBirthdate("01.01.2015"); | ||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.insertNote("test"); | ||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.selectCashPaymentMethod(); | ||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.clickAcceptTermsCheckbox(); | ||||||||||||||||||||||||||||||||
| browser.applicationDetailsSection.clickCreateApplicationButton(); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Overeni z eprihlaska existuje | ||||||||||||||||||||||||||||||||
| browser.headerMenu.goToApplicationsSection(); | ||||||||||||||||||||||||||||||||
| browser.applicationSection.search(randomPrijmeni); | ||||||||||||||||||||||||||||||||
| asserter.applicationSection.checkNumberOfApplications(1); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Odhlaseni | ||||||||||||||||||||||||||||||||
| browser.loginSection.logout(); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Prihlaseni | ||||||||||||||||||||||||||||||||
| browser.loginSection.clickLoginMenuLink(); | ||||||||||||||||||||||||||||||||
| browser.loginSection.insertEmail("peky@email.cz"); | ||||||||||||||||||||||||||||||||
| browser.loginSection.insertPassword("Hovinko123"); | ||||||||||||||||||||||||||||||||
| browser.loginSection.clickLoginButton(); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Overeni z eprihlaska prvniho uzivatele neexistuje | ||||||||||||||||||||||||||||||||
| browser.headerMenu.goToApplicationsSection(); | ||||||||||||||||||||||||||||||||
| browser.applicationSection.search(randomPrijmeni); | ||||||||||||||||||||||||||||||||
| asserter.applicationSection.checkApplicationsTableIsEmpty(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||
| void changePasswordTest() { | ||||||||||||||||||||||||||||||||
| var noveHeslo = "NoveHeslo123"; | ||||||||||||||||||||||||||||||||
| var puvodniHeslo = "Hovinko123"; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Prihlaseni | ||||||||||||||||||||||||||||||||
| browser.loginSection.clickLoginMenuLink(); | ||||||||||||||||||||||||||||||||
| browser.loginSection.insertEmail("peky@email.cz"); | ||||||||||||||||||||||||||||||||
| browser.loginSection.insertPassword(puvodniHeslo); | ||||||||||||||||||||||||||||||||
| browser.loginSection.clickLoginButton(); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Zmena hesla | ||||||||||||||||||||||||||||||||
| browser.profileSection.goToProfilePage(); | ||||||||||||||||||||||||||||||||
| browser.profileSection.insertPassword(noveHeslo); | ||||||||||||||||||||||||||||||||
| browser.profileSection.insertPasswordVerification(noveHeslo); | ||||||||||||||||||||||||||||||||
| browser.profileSection.clickChangeButton(); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Prodleva nez zmizi pop up | ||||||||||||||||||||||||||||||||
| browser.waitFor(9); | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace 9-second hard wait with explicit wait for popup dismissal. The 9-second hard-coded sleep significantly slows down the test and is unreliable. The popup might disappear sooner or take longer. Use an explicit wait that polls for the popup element to become invisible or stale. 🔧 Suggested improvementReplace the hard wait with an explicit wait that polls for the popup to disappear. For example (assuming the popup has a predictable selector): // Instead of: browser.waitFor(9);
// Use explicit wait for popup to disappear, e.g.:
// browser.waitForElementToBeInvisible(".popup-selector", 10);Check if your test framework provides a utility for waiting on element invisibility. 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Odhlaseni | ||||||||||||||||||||||||||||||||
| browser.loginSection.logout(); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Prihlaseni s novym heslem | ||||||||||||||||||||||||||||||||
| browser.loginSection.clickLoginMenuLink(); | ||||||||||||||||||||||||||||||||
| browser.loginSection.insertEmail("peky@email.cz"); | ||||||||||||||||||||||||||||||||
| browser.loginSection.insertPassword(noveHeslo); | ||||||||||||||||||||||||||||||||
| browser.loginSection.clickLoginButton(); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Overeni prihlaseni | ||||||||||||||||||||||||||||||||
| asserter.checkIsLoggedIn(); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Zmena hesla zpet na puvodni | ||||||||||||||||||||||||||||||||
| browser.profileSection.goToProfilePage(); | ||||||||||||||||||||||||||||||||
| browser.profileSection.insertPassword(puvodniHeslo); | ||||||||||||||||||||||||||||||||
| browser.profileSection.insertPasswordVerification(puvodniHeslo); | ||||||||||||||||||||||||||||||||
| browser.profileSection.clickChangeButton(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+155
to
+192
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Password change test lacks proper cleanup on failure. If the test fails after changing the password (line 170) but before changing it back (line 191), the user account 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package cz.czechitas.automation.assertion; | ||
|
|
||
| import cz.czechitas.automation.ElementFinderInterface; | ||
|
|
||
| import javax.annotation.ParametersAreNonnullByDefault; | ||
| import java.util.Objects; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| @ParametersAreNonnullByDefault | ||
| public class OrderAssertion { | ||
|
|
||
| private final ElementFinderInterface elementFinder; | ||
|
|
||
| OrderAssertion(ElementFinderInterface elementFinder) { | ||
| this.elementFinder = Objects.requireNonNull(elementFinder); | ||
| } | ||
|
|
||
| public void checkIcoFieldContainsValue(String ico) { | ||
| var icoField = elementFinder.findByCssSelector("#ico"); | ||
| assertThat(icoField.getAttribute("value")).isEqualTo(ico); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
Repository: czechitas/java-test-automation
Length of output: 298
Remove the duplicated test
navigateToParentInstructionsAndFormsTestnavigateToParentInstructionsAndFormsTestexists in bothsrc/test/java/cz/czechitas/automation/MyFirstTest.java(line 14) andsrc/test/java/cz/czechitas/automation/ExampleTest.java(line 39). Keep a single copy to avoid maintenance overhead and confusion, and delete the duplicate from one class.🤖 Prompt for AI Agents