{"id":14978808,"url":"https://github.com/tahanima/selenium-java-test-automation-architecture","last_synced_at":"2025-04-06T18:15:11.411Z","repository":{"id":37414510,"uuid":"449344980","full_name":"Tahanima/selenium-java-test-automation-architecture","owner":"Tahanima","description":"Ready-to-use UI Test Automation Architecture using Java and Selenium WebDriver.","archived":false,"fork":false,"pushed_at":"2024-07-19T11:13:20.000Z","size":181,"stargazers_count":202,"open_issues_count":5,"forks_count":105,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-03-30T15:11:11.540Z","etag":null,"topics":["assertj","cicd","data-driven-tests","e2e-boilerplate","e2e-framework","extentreports","github-actions","java","selenium","selenium-webdriver","test-automation","test-automation-framework","test-automation-java","testing","testng","webdriver"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tahanima.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://www.buymeacoffee.com/tahanima"]}},"created_at":"2022-01-18T15:42:32.000Z","updated_at":"2025-03-02T20:20:18.000Z","dependencies_parsed_at":"2025-01-15T01:14:42.797Z","dependency_job_id":"e6ca9a29-491b-4945-ab45-b0e87fff688c","html_url":"https://github.com/Tahanima/selenium-java-test-automation-architecture","commit_stats":{"total_commits":90,"total_committers":3,"mean_commits":30.0,"dds":0.2666666666666667,"last_synced_commit":"324fe042eeb213e35f4f8b1fd7c40e91c2060b53"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tahanima%2Fselenium-java-test-automation-architecture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tahanima%2Fselenium-java-test-automation-architecture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tahanima%2Fselenium-java-test-automation-architecture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tahanima%2Fselenium-java-test-automation-architecture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tahanima","download_url":"https://codeload.github.com/Tahanima/selenium-java-test-automation-architecture/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247526764,"owners_count":20953143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assertj","cicd","data-driven-tests","e2e-boilerplate","e2e-framework","extentreports","github-actions","java","selenium","selenium-webdriver","test-automation","test-automation-framework","test-automation-java","testing","testng","webdriver"],"created_at":"2024-09-24T13:58:26.910Z","updated_at":"2025-04-06T18:15:11.386Z","avatar_url":"https://github.com/Tahanima.png","language":"Java","funding_links":["https://www.buymeacoffee.com/tahanima"],"categories":[],"sub_categories":[],"readme":"# Selenium Java Test Automation Architecture\n\nReady-to-use UI Test Automation Architecture using Java and Selenium WebDriver. \n\n## Installation Steps\n\nIn order to use the framework:\n\n1. [Fork](https://github.com/Tahanima/selenium-java-test-automation-architecture/fork) the repository.\n2. Clone, i.e, download your copy of the repository to your local machine using\n```\ngit clone https://github.com/[your_username]/selenium-java-test-automation-architecture.git\n```\n3. Import the project in [IntelliJ IDEA](https://www.jetbrains.com/idea/download/).\n4. Make your desired changes.\n5. Use IntelliJ IDEA to run your desired tests. Alternatively, you can use the terminal to run the tests, for example `./gradlew test -Dbrowser=firefox -Dheadless=false` to run all the tests using the firefox browser in headful mode.\n6. To see the report, go to the `testoutput` folder in the project root and then go to the `report` folder.\n\n## Languages and Frameworks\n\nThe project uses the following:\n\n- *[Java 11](https://openjdk.java.net/projects/jdk/11/)* as the programming language.\n- *[Selenium WebDriver](https://www.selenium.dev/)* as the web browser automation framework using the Java binding.\n- *[Univocity Parsers](https://www.univocity.com/pages/univocity_parsers_tutorial)* to parse and handle CSV files.\n- *[TestNG](https://testng.org/doc/)* as the testing framework.\n- *[AssertJ](https://assertj.github.io/doc/)* as the assertion library.\n- *[Lombok](https://projectlombok.org/)* to generate getters.\n- *[Owner](http://owner.aeonbits.org/)* to minimize the code to handle properties file.\n- *[Extent Reports](https://www.extentreports.com/)* as the test reporting strategy.\n- *[Selenium Shutterbug](https://github.com/assertthat/selenium-shutterbug)* for capturing screenshots.\n- *[Gradle](https://gradle.org/)* as the Java build tool.\n- *[IntelliJ IDEA](https://www.jetbrains.com/idea/)* as the IDE.\n\n## Project Structure\n\nThe project is structured as follows:\n\n```bash\n📦 selenium-java-test-automation-architecture\n├─ .github\n│  ├─ FUNDING.yml\n│  ├─ dependabot.yml\n│  └─ workflows\n│     └─ test-execution.yml\n├─ .gitignore\n├─ LICENSE\n├─ README.md\n├─ build.gradle\n├─ gradle\n│  └─ wrapper\n│     ├─ gradle-wrapper.jar\n│     └─ gradle-wrapper.properties\n├─ gradlew\n├─ gradlew.bat\n├─ script\n│  └─ install_chrome.sh\n├─ settings.gradle\n└─ src\n   ├─ main\n   │  └─ java\n   │     └─ io\n   │        └─ github\n   │           └─ tahanima\n   │              ├─ config\n   │              │  ├─ Configuration.java\n   │              │  └─ ConfigurationManager.java\n   │              ├─ dto\n   │              │  ├─ BaseDto.java\n   │              │  ├─ LoginDto.java\n   │              │  └─ ProductsDto.java\n   │              ├─ factory\n   │              │  ├─ BasePageFactory.java\n   │              │  └─ BrowserFactory.java\n   │              ├─ report\n   │              │  └─ ExtentReportManager.java\n   │              └─ ui\n   │                 ├─ component\n   │                 │  ├─ BaseComponent.java\n   │                 │  ├─ Header.java\n   │                 │  └─ SideNavMenu.java\n   │                 └─ page\n   │                    ├─ BasePage.java\n   │                    ├─ LoginPage.java\n   │                    └─ ProductsPage.java\n   └─ test\n      ├─ java\n      │  └─ io\n      │     └─ github\n      │        └─ tahanima\n      │           ├─ e2e\n      │           │  ├─ BaseTest.java\n      │           │  ├─ LoginTest.java\n      │           │  └─ ProductsTest.java\n      │           └─ util\n      │              ├─ DataProviderUtil.java\n      │              ├─ TestListener.java\n      │              └─ TestRetry.java\n      └─ resources\n         ├─ config.properties\n         └─ testdata\n            ├─ login.csv\n            ├─ login.json\n            ├─ products.csv\n            └─ products.json\n```\n\n## Basic Usage\n\n- ### Configuration\n  The project uses a [*config.properties*](./src/test/resources/config.properties) file to manage global configurations such as browser type and base url.\n  \n  1. To add a new property, register a new entry in this file.\n      ```\n      key=value\n      ```\n    \n      Then, add a method in the [*Configuration*](./src/main/java/io/github/tahanima/config/Configuration.java) interface in the below format.\n      ```java\n      @Key(\"key\")\n      dataType key();\n      ```\n    \n      For example, let's say I want to add a new property named `context` with the value `dev`. In the `config.properties` file, I'll add:\n      ```\n      context=dev\n      ```\n    \n      In the `Configuration` interface, I'll add:\n      ```java\n      @Key(\"context\")\n      String context();\n      ```\n    \n      To use your newly created property, you need to use the below import statement.\n      ```java\n      import static io.github.tahanima.config.ConfigurationManager.config;\n      ```\n    \n      Then, you can call `config().key()` to retrieve the value of your newly created property. For the example I've provided, I need to call `config().context()`.\n\n  2. You can supply the properties present in the `config.properties` file as system properties in your test via gradle.\n      ```bash\n      ./gradlew test -Dkey1=value1 -Dkey2=value2\n      ```\n      \n- ### Test Data\n  The project uses *csv* or *json* file to store test data and [*univocity-parsers*](https://github.com/uniVocity/univocity-parsers) to retrieve the data and map it to a Java bean.\n\n  To add configurations for new test data, add a new Java bean in the [*dto*](./src/main/java/io/github/tahanima/dto) package. For example, let's say I want to add test data for a `User` with the attributes `First Name` and `Last Name`. The code for this is as follows:\n\n   ```java\n   package io.github.tahanima.dto;\n\n   import com.univocity.parsers.annotations.Parsed;\n\n   import lombok.Getter;\n   import lombok.ToString;\n\n   @Getter\n   @ToString(callSuper = true)\n   public class UserDto extends BaseDto {\n\n       @Parsed(field = \"First Name\", defaultNullRead = \"\")\n       private String firstName;\n\n       @Parsed(field = \"Last Name\", defaultNullRead = \"\")\n       private String lastName;\n   }\n   ```\n   Note that the class extends from BaseDto and thus, inherits the attributes `Test Case ID` and `Test Case Description`.\n\n   Now, in the [*testdata*](./src/test/resources/testdata) folder you can add a csv file `user.csv` for `User` with the below contents and use it in your tests.\n   ```\n   Test Case ID,Test Case Description,First Name,Last Name\n   TC-1,Successful user creation,Tahanima,Chowdhury\n   ```\n  \n   Alternately, you can use a json file `user.json` with the below contents and use it in your tests.\n   ```json\n   [\n     {\n       \"testCaseId\": \"TC-1\",\n       \"testCaseDescription\": \"Successful user creation\",\n       \"firstName\": \"Tahanima\",\n       \"lastName\": \"Chowdhury\"\n     }\n   ]\n   ```\n   For reference, check [this](./src/main/java/io/github/tahanima/dto/LoginDto.java), [this](./src/test/resources/testdata/login.csv) and [this](./src/test/java/io/github/tahanima/e2e/LoginTest.java).\n\n- ### Browser\n  The project contains the implementation of the *Chrome* and *Firefox* browsers. If you want to include an implementation of a new browser type, add the relevant codes in the [*BrowserFactory*](./src/main/java/io/github/tahanima/factory/BrowserFactory.java) enum.\n\n  For example, let's say I want to add the `Edge` browser to the `BrowserFactory` enum. The code for this is:\n  ```java\n  EDGE {\n      @Override\n      public WebDriver getDriver() {\n          WebDriver driver = new EdgeDriver(getOptions());\n\n          driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(config().timeout()));\n          driver.manage().window().maximize();\n\n          return driver;\n      }\n\n      private EdgeOptions getOptions() {\n          EdgeOptions options = new EdgeOptions();\n\n          options.setAcceptInsecureCerts(true);\n\n          if (Boolean.TRUE.equals(config().headless())) {\n              options.addArguments(\"--headless=new\");\n          }\n\n          return options;\n      }\n  }\n  ```\n\n  Now, you can launch all your tests in the `Edge` browser by either setting the property `browser` to `edge` in the [*config.properties*](./src/test/resources/config.properties) file or as a system property via gradle.\n\n- ### Page Objects and Page Component Objects\n  The project uses [*Page Objects* and *Page Component Objects*](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/) to capture the relevant behaviors of a web page. Check the [*ui*](./src/main/java/io/github/tahanima/ui) package for reference.\n\n- ### Tests\n  The project uses *TestNG* as the test runner. Check [this implementation](./src/test/java/io/github/tahanima/e2e/LoginTest.java) for reference.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftahanima%2Fselenium-java-test-automation-architecture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftahanima%2Fselenium-java-test-automation-architecture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftahanima%2Fselenium-java-test-automation-architecture/lists"}