{"id":16536715,"url":"https://github.com/eliasnogueira/selenium-dynamic-grid-example","last_synced_at":"2025-10-28T13:31:14.128Z","repository":{"id":147153562,"uuid":"566056031","full_name":"eliasnogueira/selenium-dynamic-grid-example","owner":"eliasnogueira","description":"Example project that run multi-browser web test automation in parallel using Selenium Grid and Docker","archived":false,"fork":false,"pushed_at":"2024-10-27T17:59:22.000Z","size":48,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-01T15:11:22.604Z","etag":null,"topics":["grid","java","parallel-tests","selenium-webdriver","test-automation"],"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/eliasnogueira.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.adoc","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}},"created_at":"2022-11-14T21:57:39.000Z","updated_at":"2024-10-27T17:59:25.000Z","dependencies_parsed_at":"2023-12-17T14:23:22.204Z","dependency_job_id":"36c4bdfc-3a68-4a6b-a9ff-6b262fd2682b","html_url":"https://github.com/eliasnogueira/selenium-dynamic-grid-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliasnogueira%2Fselenium-dynamic-grid-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliasnogueira%2Fselenium-dynamic-grid-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliasnogueira%2Fselenium-dynamic-grid-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliasnogueira%2Fselenium-dynamic-grid-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eliasnogueira","download_url":"https://codeload.github.com/eliasnogueira/selenium-dynamic-grid-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238654812,"owners_count":19508491,"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":["grid","java","parallel-tests","selenium-webdriver","test-automation"],"created_at":"2024-10-11T18:32:55.886Z","updated_at":"2025-10-28T13:31:08.869Z","avatar_url":"https://github.com/eliasnogueira.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Selenium Dynamic Grid Example\n\nSelenium 4 has the Selenium Grid project where we can use docker images to run the test targeting a container with a browser.\nWe can approach this in different ways, and one of the most beneficial for multi-browser testing is using the Dynamic Grid.\n\nNote that this project contains basic examples using TestNG and JUnit 5.\nThe main intent is to give you examples to run multi-browser parallel tests.\n\nDon’t forget to give this project a star!\n\n== How to run this project\n\n. Navigate to the `grid` folder:\n+\n[source,bash]\n----\ncd grid\n----\n\n. Start the Selenium Grid:\n* if you have a MacOS machine first run in your Terminal `socat -4 TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock`:\n\n[source,shell]\n----\ndocker-compose up\n----\n\n. Open the grid dashboard at http://localhost:4444/\n\n. Run the test:\n* `src/test/java/com.eliasnogueira.junit.MultiBrowserDetectorTest` for JUnit 5\n* `src/test/resources/testng/parallel.xml` for TestNG\n\n== How this project is structured\n\n=== Grid\n\nIn the `grid` folder we will see two files:\n* `docker-compose.yml`\n* `config.toml`\n\n=== General\n\n==== Configuration\n\nThe `general.properties` file has basic common values like URL, timeout, and headless execution.\nThe `grid.properties` file has the url and port of the grid, to configure it.\n\nNormally we add those values in the properties files to easily.\nYou can change these values running the test using a CI/CD tool.\n\nThe class `Configuration` has all the bindings to the properties file, where the `ConfigurationManager` is responsible to load it.\nTo make this happen the Owner library is in use.\n\n==== Browser Factory\n\nThe `BrowserFactory` class is an enumeration that returns the browser options.\nThese driver options are used in the `TargetFactory` which will create a remote execution using the selected browser.\nThe `DriverManager` adds the driver in a thread to avoid concurrency issues.\n\nBoth `BaseWeb` classes, placed in the `test` package use the `TargetFactory` to create the remote browser instance for the test execution.\n\n[source,java]\n----\ndriver=new TargetFactory().createInstance(browser);\n----\n\n=== Using TestNG to run multi-browser parallel tests\n\nThe TestNG tests are located at `src/test/java/com.eliasnogueira.testng` and they are composed by:\n\n- `BaseWeb`: base test class which has the pre and post-test conditions to create the browser instance and quit it\n- `BrowserDetectorTest`: test run a parameterized test based on the implemented browsers\n\n==== How TestNG runs the tests in parallel\n\nTestNG has a built-in feature to run parallel tests using a test suite, which is an XML file to group different tests for execution.\nThe `parallel` attribute of the `\u003csuite\u003e` tag is the indication of what should be run in parallel.\n\nThe `BaseWeb` class has a pre-condition that will match the required parameter with the parameter set by each test in the `src/test/java/resources/testng/parallel.xml` file.\n\n=== Using JUnit to run multi-browser tests in parallel\n\nThe JUnit 5 tests are located at `src/test/java/com.eliasnogueira.junit` and they are composed by:\n\n- `BaseWeb`: base test class which has the post-test condition to quit the browser and a method to create the browser instance which will be used by the test\n- `MultiBrowserDetectorTest`: test run a parameterized test based on the implemented browsers\n\n==== How JUnit run the tests in parallel\n\nWe know that the `MultiBrowserDetectorTest` will run the test for each browser present in the `BrowserFactory` class.\n\nThe file `junit-platform.properties` has configurations set to run the tests in parallel, in a concurrent mode, and with a fixed number of parallel tests.\nYou can take a look at the file to see the configurations set.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliasnogueira%2Fselenium-dynamic-grid-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feliasnogueira%2Fselenium-dynamic-grid-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliasnogueira%2Fselenium-dynamic-grid-example/lists"}