Refer step by step tutorial for detailed explanation.
- How to create maven build project
- Write tests using testNG
- Implement page object model
- Singleton pattern for driver instantiation and getter / setter
- Running the tests using maven surefire plugin
- Run tests in command prompt
- Run tests in Docker containers
Refer below links for basic understanding of selenium, Maven & testNG
Open command prompt, navigate to project directory & run below command
mvn test
//default runs in chrome browser
mvn test -Dbrowser=firefox
Note -
Make sure you have docker desktop installed
Docker is currently running
Navigate to docker directory cd docker
Run below command to run the docker conntainers
docker-compose -f docker-compose-hubNode.yml up -d
Now in another terminal, run any of below command to run the tests inside the container
mvn test -Dplatform=remote
//default runs in chrome browser
mvn test -Dbrowser=firefox -Dplatform=remote
See the tests running insider container
Navigate to browser and load this url localhost:4444
After running the tests, stop the containers
docker-compose -f docker-compose-hubNode.yml down