|
| 1 | +# Running Selenium Java Tests |
| 2 | +The following steps will guide you on how to |
| 3 | +run Selenium Java tests using a repository |
| 4 | +of `SeleniumHQ/seleniumhq.github.io` examples. |
| 5 | + |
| 6 | +## Initial Setup |
| 7 | + |
| 8 | +### Prerequisites |
| 9 | + |
| 10 | +Ensure that Java Development Kit (JDK) and Maven |
| 11 | +are installed on your system. If they are not installed, |
| 12 | +you will need to download and install them. You can |
| 13 | +find detailed installation guides for both on their |
| 14 | +respective official sites. |
| 15 | + |
| 16 | +### Clone the repository |
| 17 | +First, we need to get the Selenium Java examples |
| 18 | +on your local machine. This can be done by |
| 19 | +cloning the `SeleniumHQ/seleniumhq.github.io` Git repository. |
| 20 | +Run the following command in your terminal: |
| 21 | + |
| 22 | +```bash |
| 23 | +git clone https://github.com/SeleniumHQ/seleniumhq.github.io.git |
| 24 | +``` |
| 25 | +## Navigate to the java directory |
| 26 | +After cloning the repository, navigate into the |
| 27 | +directory where the Selenium Java examples are |
| 28 | +located. Run the following command: |
| 29 | + |
| 30 | +```bash |
| 31 | +cd seleniumhq.github.io/examples/java |
| 32 | +``` |
| 33 | + |
| 34 | +## Running the Tests |
| 35 | +### Install dependencies |
| 36 | +Before running the tests, we need to install all |
| 37 | +necessary dependencies. Maven, a software |
| 38 | +project management tool, can do this for us. |
| 39 | +Run the following command: |
| 40 | + |
| 41 | +```bash |
| 42 | +mvn test-compile |
| 43 | +``` |
| 44 | + |
| 45 | +### Run all tests |
| 46 | +To verify if everything is installed correctly and |
| 47 | +functioning properly, we should run all |
| 48 | +available tests. This can be done with the following command: |
| 49 | + |
| 50 | +```bash |
| 51 | +mvn test |
| 52 | +``` |
| 53 | + |
| 54 | +Please be patient! If this is your first time running these tests, |
| 55 | +it might take a while to download and verify all necessary browser drivers. |
| 56 | + |
| 57 | +## Execute a specific example |
| 58 | +To run a specific Selenium Java example, use the following command: |
| 59 | +```bash |
| 60 | +mvn exec:java -D"exec.mainClass"="dev.selenium.getting_started.FirstScript" -D"exec.classpathScope"=test |
| 61 | +``` |
| 62 | + |
| 63 | +Make sure to replace `dev.selenium.getting_started.FirstScript` with the path and name of the example you want to run. |
0 commit comments