|
1 | | -startUsingSeleniumWebDriver |
| 1 | +Start Using Selenium WebDriver |
2 | 2 | =========================== |
3 | 3 |
|
4 | | -**Recommend using the start Using Selenium 4 repo. This repo is for Selenium 3** |
5 | | -- [Start Using Selenium 4](https://github.com/eviltester/startUsingSelenium4Java) |
| 4 | +[](https://github.com/eviltester/startUsingSeleniumWebDriver/actions) |
6 | 5 |
|
| 6 | +Simple start example for Selenium 4 with java and JUnit 5. |
7 | 7 |
|
8 | | -**This repo is deprecated and based on WebDriver 3** |
| 8 | +- For previous versions of WebDriver and JUnit see the releases page. |
9 | 9 |
|
| 10 | +It has the basic startup and configuration for a test using Chrome Driver. |
10 | 11 |
|
11 | | -Source code to support getting started using Selenium WebDriver with Java |
| 12 | +## Pre-Requisites |
12 | 13 |
|
13 | | -The source code has only really been uploaded in case people encounter problems following the instructions or make a very simple mistake that they cannot figure out. |
| 14 | +Pre-requisites are ([use quick start guide to install these](https://github.com/eviltester/startUsingJavaJUnit5/blob/main/speedrun_install_java_checklist.md)): |
14 | 15 |
|
15 | | -Please read the comments below, and the source code comments if you are having trouble starting work with Firefox. |
| 16 | +- a Java SDK |
| 17 | +- maven |
| 18 | +- and and IDE Install. |
16 | 19 |
|
| 20 | +The code uses JUnit 5 so you can follow the Quick Start Guide in the "[Getting Started with JUnit 5 repo](https://github.com/eviltester/startUsingJavaJUnit5)" |
17 | 21 |
|
18 | | -## Steps |
| 22 | +- [Quick start guide is here](https://github.com/eviltester/startUsingJavaJUnit5/blob/main/speedrun_install_java_checklist.md) |
19 | 23 |
|
20 | | -* First install Java, Maven and IntelliJ |
21 | | - * [Java Install Checklist](https://github.com/eviltester/startUsingJavaJUnit/blob/master/speedrun_install_java_checklist.md) |
22 | | -* Second install Firefox, GeckoDriver, Chrome and ChromeDriver |
23 | | - * [WebDriver Install Checklist](https://github.com/eviltester/startUsingSeleniumWebDriver/blob/master/speedrun_install_checklist.md) |
| 24 | +## Start By |
24 | 25 |
|
| 26 | +Clone or download the repo as a zip. |
25 | 27 |
|
26 | | -## Run a Test on your chosen browser |
| 28 | +From the unzipped top level directory containing the 'pom.xml' file, you can run the test using: |
27 | 29 |
|
28 | | -If you are on a mac and have allowed Remote Execution in the Safari browser then you can use the command line: |
| 30 | +`mvn test` |
29 | 31 |
|
30 | | -`mvn test -Dtest=MyFirstSafariTest` |
| 32 | +And can run it using headless mode by setting the environment variable `BROWSER_STATE` to have the value "`Headless`" |
31 | 33 |
|
32 | | -If you are using Chrome and have added ChromeDriver to the path then use the command line: |
| 34 | +e.g. |
33 | 35 |
|
34 | | -`mvn test -Dtest=MyFirstChromeTest` |
| 36 | +``` |
| 37 | +BROWSER_STATE=Headless mvn test |
| 38 | +``` |
35 | 39 |
|
36 | | -If you are using Firefox and have added GeckoDriver to the path then use the command line: |
| 40 | +## Use the code |
37 | 41 |
|
38 | | -`mvn test -Dtest=MyFirstTest` |
| 42 | +Open the project in Intellij by opening the folder containing the 'pom.xml' or open the 'pom.xml'. |
39 | 43 |
|
40 | | -Do not run `mvn test` because some of the tests are Platform and WebDriver version dependant and at least one will probably fail. |
| 44 | +## Github Actions |
41 | 45 |
|
42 | | -## Update `pom.xml` |
| 46 | +The repo also has [Github actions](https://github.com/eviltester/startUsingJavaJUnit5/blob/main/.github/workflows/build.yml) to run the test in headless mode periodically. |
43 | 47 |
|
44 | | -You may also wish to edit the `pom.xml` file and change the version of Selenium WebDriver to the current version listed on [seleniumhq.org](https://www.seleniumhq.org) in the [downloads section](https://www.seleniumhq.org/download/) |
| 48 | +## About Selenium WebDriver 4 |
45 | 49 |
|
| 50 | +This uses Selenium 4. |
46 | 51 |
|
47 | | -*Author: Alan Richardson* |
| 52 | +Selenium 4 comes with a builtin WebDriver Manager |
48 | 53 |
|
49 | | -* [EvilTester.com](https://eviltester.com) |
50 | | -* [Compendium Developments](https://compendiumdev.co.uk) |
| 54 | +https://www.selenium.dev/blog/2022/introducing-selenium-manager/ |
51 | 55 |
|
| 56 | +This will automatically download the drivers required to allow Selenium to use the chosen webdriver. |
52 | 57 |
|
| 58 | +e.g. if you instantiate a `new ChromeDriver()` the WebDriver Manager will download the drivers for |
| 59 | +Chrome and run the tests against Chrome. |
53 | 60 |
|
54 | | -## Running with Chrome |
| 61 | +You just need to download and have Chrome installed. |
55 | 62 |
|
56 | | -If you are using Chrome and have added ChromeDriver to the path then use the command line: |
| 63 | +Similarly, with Firefox and Edge, just download the browser and Selenium will download the correct driver. |
57 | 64 |
|
58 | | -`mvn test -Dtest=MyFirstChromeTest` |
59 | | - |
60 | | -## Running with Firefox |
61 | | - |
62 | | -If you are using Firefox and have added GeckoDriver to the path then use the command line: |
63 | | - |
64 | | -`mvn test -Dtest=MyFirstTest` |
65 | | - |
66 | | -## Earlier versions of Firefox |
67 | | - |
68 | | -If you wish to use earlier versions of Firefox then see the repo: |
69 | | - |
70 | | -https://github.com/eviltester/startUsingLegacyFirefoxWebDriver |
71 | 65 |
|
0 commit comments