🌟SOME FEATURES IN FRAMEWORK
- Run the parallel Scenario on feature file
- Cucumber Report
- Extent Report
- Allure Report
- Send Mail after the run test (Report information and HTML file attachment)
- Write Log to file
- Record video and Screenshot test case
- Read data test from Excel file (xlsx, csv, json,...)
- Base function in the package: utils, helpers
- Read data test from Json file
- Main keyword is WebUI
- Sample test feature
- Use DataFaker and JavaFaker to generate data
- Javadoc for this source
-
Install Java JDK (recommend JDK >= 17)
-
Install Chrome Browser, Edge Browser, Firefox Browser
-
Setup Allure environment: https://mvnrepository.com/artifact/io.qameta.allure/allure-java-commons or https://anhtester.com/blog/selenium-java/selenium-java-tai-nguyen-cai-dat-moi-truong) Download jar and setting Variable Environment as Java JDK
-
IntelliJ IDEA is the best choice (easy to change JDK version)
1. Run parallel the test case
-
Run Cucumber TestRunner from src/test/java/anhtester/com/runners
-
Run Feature file (src/test/resources/features/)
-
Run Feature in suite XML (src/test/resources/suites/)
-
Run Feature from Maven pom.xml file (
mvn clean test) -
mvn clean test -Dbrowser=chrome -
mvn clean test -Dbrowser=edge -
mvn clean test -Dbrowser=firefox
2. Cucumber Report
3. Extent Report
- Config from src/test/resources/extent.properties
- Config PDF from src/test/resources/pdf-config.yaml
4. Allure Report
- Open Terminal: allure serve target/allure-results or
allure generate --single-file target/allure-results -o allure-report --clean
- Insert @Step("title/message") above @Test or any Method in the project
- (As sample picture above step 3)
5. Send Mail after the run test
- Config true/false in config.properties (src/test/resources/config/config.properties)
- send_email_to_users=true is enable send mail
- Config mail with email and password in src/main/java/anhtester/com/mail/EmailConfig.java
- Note: if Gmail, you use Password App
6. Write Log to file
- Call class: Log.info , Log.pass, Log.error,... (Log is a custom global class from Log4j2) (import anhtester.com.utils.Log.java)
7. Record video and Screenshot
-
Setup in config.properties file (src/test/resources/config/config.properties)
-
screenshot_passed_steps=yes or no
-
screenshot_failed_steps=yes or no
-
screenshot_skipped_steps=yes or no
-
screenshot_all_steps=yes or no
8. Read data test from Excel file
- Create function with annotaion DataSupplier on src/main/java/anhtester/com/utils/DataProviderUtils.java
- Call the name of DataSupplier above in the test cases as DataProvider of TestNG
- Read excel with Map and Hashtable
9. Base function in the package
- src/main/java/anhtester/com/utils
- src/main/java/anhtester/com/helpers
10. Read data test from JSON file
- JsonUtils class select the json file path and call "get" method with key
11. Main keyword is WebUI
- WebUI class is main keyword in Framework. It contains common functions
- How to use: WebUI.function_name
- Example: WebUI.setWindowSize(1024, 768), WebUI.screenshotElement(By by, String elementName),...
12. Call test case sample
- Run test case TestNG: src/test/java/anhtester/com/projects/website/crm/testcases
- Run test case Gherkin: src/test/resources/suites/RunSuiteFeature.xml
- Or run with maven in pom.xml file: mvn clean test
+ src/test/resources/suites/RunSuiteFeature.xml + ClientTest + SignInTest + TestHandle + TestSimpleCode 📦AutomationFrameworkCucumberTestNG ┣ 📂.github ┃ ┗ 📂workflows ┃ ┃ ┗ 📜maven.yml ┣ 📂src ┃ ┣ 📂main ┃ ┃ ┣ 📂java ┃ ┃ ┃ ┗ 📂com ┃ ┃ ┃ ┃ ┗ 📂anhtester ┃ ┃ ┃ ┃ ┃ ┣ 📂annotations ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜FrameworkAnnotation.java ┃ ┃ ┃ ┃ ┃ ┣ 📂config ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜ConfigFactory.java ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜Configuration.java ┃ ┃ ┃ ┃ ┃ ┣ 📂constants ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜FrameworkConstants.java ┃ ┃ ┃ ┃ ┃ ┣ 📂driver ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜BrowserFactory.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜DriverManager.java ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜TargetFactory.java ┃ ┃ ┃ ┃ ┃ ┣ 📂enums ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜AuthorType.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜Browser.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜CategoryType.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜FailureHandling.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜Platform.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜Project.java ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜Target.java ┃ ┃ ┃ ┃ ┃ ┣ 📂exceptions ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜FrameworkException.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜HeadlessNotSupportedException.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜InvalidPathForExcelException.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜InvalidPathForExtentReportFileException.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜InvalidPathForFilesException.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜InvalidRemoteWebDriverURLException.java ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜TargetNotValidException.java ┃ ┃ ┃ ┃ ┃ ┣ 📂helpers ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜CaptureHelpers.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜DatabaseHelpers.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜ExcelHelpers.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜FileHelpers.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜Helpers.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜PropertiesHelpers.java ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜ScreenRecoderHelpers.java ┃ ┃ ┃ ┃ ┃ ┣ 📂keywords ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜WebUI.java ┃ ┃ ┃ ┃ ┃ ┣ 📂mail ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜EmailAttachmentsSender.java ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜EmailConfig.java ┃ ┃ ┃ ┃ ┃ ┣ 📂report ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜AllureManager.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜ExtentReportManager.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜ExtentTestManager.java ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜TelegramManager.java ┃ ┃ ┃ ┃ ┃ ┗ 📂utils ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜BrowserInfoUtils.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜DataFakerUtils.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜DataGenerateUtils.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜DateUtils.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜DecodeUtils.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜EmailSendUtils.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜IconUtils.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜JsonUtils.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜LanguageUtils.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜LocalStorageUtils.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜LogUtils.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜ObjectUtils.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜ReportUtils.java ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜ZipUtils.java ┃ ┃ ┗ 📂resources ┃ ┃ ┃ ┣ 📂META-INF ┃ ┃ ┃ ┃ ┗ 📂services ┃ ┃ ┃ ┃ ┃ ┗ 📜io.qameta.allure.listener.TestLifecycleListener ┃ ┃ ┃ ┗ 📜log4j2.properties ┃ ┗ 📂test ┃ ┃ ┣ 📂java ┃ ┃ ┃ ┗ 📂com ┃ ┃ ┃ ┃ ┗ 📂anhtester ┃ ┃ ┃ ┃ ┃ ┣ 📂common ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜BaseTest.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜CommonPageCRM.java ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜CommonSteps.java ┃ ┃ ┃ ┃ ┃ ┣ 📂dataprovider ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜DataProviderManager.java ┃ ┃ ┃ ┃ ┃ ┣ 📂hooks ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜CucumberListener.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜Hooks.java ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜TestContext.java ┃ ┃ ┃ ┃ ┃ ┣ 📂listeners ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜AllureListener.java ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜TestListener.java ┃ ┃ ┃ ┃ ┃ ┣ 📂projects ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📂website ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📂cms ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📂pages ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜CommonPageCMS.java ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜LoginPage.java ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📂stepdefinitions ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜LoginSteps.java ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📂crm ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📂models ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜ClientModel.java ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜SignInModel.java ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📂pages ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📂Clients ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜ClientPageCRM.java ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📂Dashboard ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜DashboardPageCRM.java ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📂Projects ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜ProjectPageCRM.java ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📂SignIn ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜SignInPageCRM.java ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📂Tasks ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜TaskPage.java ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📂stepdefinitions ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜DashboardSteps.java ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜LoginSteps.java ┃ ┃ ┃ ┃ ┃ ┗ 📂runners ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜LoginCMSTestRunner.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜SigninCRMTestRunner.java ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜TestRunnerAllFeatureByTag.java ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜TestRunnerForDashboardHRM.java ┃ ┃ ┗ 📂resources ┃ ┃ ┃ ┣ 📂config ┃ ┃ ┃ ┃ ┣ 📜config.json ┃ ┃ ┃ ┃ ┣ 📜config.properties ┃ ┃ ┃ ┃ ┗ 📜data.properties ┃ ┃ ┃ ┣ 📂features ┃ ┃ ┃ ┃ ┣ 📜Dashboard.feature ┃ ┃ ┃ ┃ ┣ 📜LoginCMS.feature ┃ ┃ ┃ ┃ ┗ 📜SigninCRM.feature ┃ ┃ ┃ ┣ 📂objects ┃ ┃ ┃ ┃ ┗ 📜crm_locators.properties ┃ ┃ ┃ ┣ 📂suites ┃ ┃ ┃ ┃ ┣ 📜SuiteFeatureAll.xml ┃ ┃ ┃ ┃ ┣ 📜SuiteFeatureByTag.xml ┃ ┃ ┃ ┃ ┗ 📜SuiteFeatureLoginCMS.xml ┃ ┃ ┃ ┣ 📂testdata ┃ ┃ ┃ ┃ ┣ 📜ClientsDataExcel.xlsx ┃ ┃ ┃ ┃ ┣ 📜DOCX_File_01.docx ┃ ┃ ┃ ┃ ┣ 📜LoginCSV.csv ┃ ┃ ┃ ┃ ┗ 📜TxtFileData.txt ┃ ┃ ┃ ┣ 📜cucumber.properties ┃ ┃ ┃ ┣ 📜extent.properties ┃ ┃ ┃ ┗ 📜pdf-config.yaml ┃ ┃ ┣ 📂config ┃ ┃ ┃ ┣ 📜config.json ┃ ┃ ┃ ┣ 📜config.properties ┃ ┃ ┃ ┗ 📜data.properties ┃ ┃ ┣ 📂features ┃ ┃ ┃ ┣ 📜Dashboard.feature ┃ ┃ ┃ ┣ 📜LoginCMS.feature ┃ ┃ ┃ ┗ 📜SigninCRM.feature ┃ ┃ ┣ 📂objects ┃ ┃ ┃ ┗ 📜crm_locators.properties ┃ ┃ ┣ 📂suites ┃ ┃ ┃ ┣ 📜SuiteFeatureAll.xml ┃ ┃ ┃ ┣ 📜SuiteFeatureByTag.xml ┃ ┃ ┃ ┗ 📜SuiteFeatureLoginCMS.xml ┃ ┃ ┣ 📂testdata ┃ ┃ ┃ ┣ 📜ClientsDataExcel.xlsx ┃ ┃ ┃ ┣ 📜DOCX_File_01.docx ┃ ┃ ┃ ┣ 📜LoginCSV.csv ┃ ┃ ┃ ┗ 📜TxtFileData.txt ┃ ┃ ┣ 📜cucumber.properties ┃ ┃ ┣ 📜extent.properties ┃ ┃ ┗ 📜pdf-config.yaml ┣ 📜.gitignore ┣ 📜CHANGELOG.txt ┣ 📜pom.xml ┗ 📜README.md Anh Tester Blog: https://anhtester.com/

















