Skip to content

Commit

Permalink
Add Gradle 'personality' property; remove Maven POM and docs (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbabcoc committed Jan 23, 2023
1 parent b57a7c6 commit c0b803e
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 1,018 deletions.
27 changes: 6 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ With the release of **Selenium Foundation** version _26.3.4_, automation of Maci
* [Building Selenium Foundation](#building-selenium-foundation)
* [Building in Eclipse](#building-in-eclipse)
* [Building from Command Line](#building-from-command-line)
* [Maven Support](#maven-support)
* [Maven Build Script](#maven-build-script---mvn-buildsh)
* [Running Browser Unit Tests](#running-browser-unit-tests)
* [Getting Started](#getting-started)
* [Required Configuration](#required-configuration)
Expand Down Expand Up @@ -92,30 +90,17 @@ Use the `install` task to install SNAPSHOT builds in your local Maven repository

> **`gradle install`**
#### Maven Support

Although Gradle is used to produce official releases, **Selenium Foundation** also includes a fully functional Maven POM file.

> **`mvn package`**
Note that the version number in this POM file is merely a placeholder - a token that gets replaced during the normal build process. Finalized, functional `POMs` can be found within the **Selenium Foundation** JARs themselves at:

> **`META-INF/maven/com.nordstrom.ui-tools/selenium-foundation/pom.xml`**
#### Maven Build Script - `mvn-build.sh`

Unlocking the full capabilities of the Maven project file of **Selenium Foundation** requires the specification of several correlated properties. To simplify the process of building and testing the project with Maven, we've provided a script that packages up the details in a concise format. To build the project with the version number from `gradle.properties`:

> **`./mvn-build.sh`**
#### Running Browser Unit Tests

By default, the unit tests that run after the build completes are the support feature tests (which don't require a browser). The Gradle and Maven project files provide a set of browser profiles, one for each supported browser. By specifying one of these profiles, you activate dependencies, settings, and driver plug-in for the corresponding browser.
By default, the unit tests that run after the build completes are the support feature tests (which don't require a browser). The Gradle project file provides a set of browser profiles, one for each supported browser. By specifying one of these profiles, you activate dependencies, settings, and driver plug-in for the corresponding browser.

> **`gradle test -Pbrowsers=espresso`** # run Android Espresso unit tests
> **`./mvn-build.sh -t -b firefox -h`** # run Mozilla Firefox unit tests in "headless" mode
> **`gradle test -Pbrowsers=filefox -Ppersonality=firefox.headless`** # run Mozilla Firefox unit tests in "headless" mode
> **`gradle test -Pbrowsers=htmlunit -Ppersonality=htmlunit.nojs`** # run HtmlUnit unit tests without JavaScript support
The `personality` property directs **Selenium Foundation** to run the unit tests on browsers with the specified named capabilities. Available personalities are defined by each driver plug-in, and the list of personalities supported by the current Grid is shown in the console output. For example:

The second command uses the Maven build script instead of invoking Maven directly. This replicates the behavior of the Gradle project, consolidating the entire configuration set into a single named value.
> `http://192.168.254.20:4445/wd/hub: Personalities => [chrome, chrome.headless]`
A complete list of supported browser profiles can be found [here](https://github.com/sbabcoc/Selenium-Foundation/blob/master/docs/ConfiguringProjectSettings.md#grid-configuration-for-selenium-foundation-unit-tests),

Expand Down
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import org.apache.tools.ant.filters.ReplaceTokens

plugins {
id 'java-library'
id 'eclipse'
id 'maven-publish'
id 'jacoco'
id 'signing'
Expand Down Expand Up @@ -30,6 +31,10 @@ if (project.hasProperty('browsers')) {
}
}

if (project.hasProperty('personality')) {
System.setProperty('selenium.browser.name', ext.personality)
}

def archiveVer = null
def verBits = scmVersion.version.split('-')
def seleniumApi = 's' + profile.charAt(8)
Expand Down
2 changes: 1 addition & 1 deletion docs/ConfiguringProjectSettings.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ The **`GRID_PLUGINS`** setting specifies a semicolon-delimited list of fully-qua
#### Grid Configuration for Selenium Foundation unit tests

By default, the unit tests are [configured](LocalGridConfiguration.md) to run the "support" tests, which don't require browser sessions. The local Grid instance launched for this configuration runs in "servlet container" mode. The Maven and Gradle project file define sets of profiles, one for each supported browser, which specify the corresponding dependencies, settings, and driver plugin needed to run the unit tests for that browser.
By default, the unit tests are [configured](LocalGridConfiguration.md) to run the "support" tests, which don't require browser sessions. The local Grid instance launched for this configuration runs in "servlet container" mode. The Gradle project file defines a set of profiles, one for each supported browser, which specify the corresponding dependencies, settings, and driver plugin needed to run the unit tests for that browser.

| Profile | Browser / Appium Engine |
| --- |:---:|
Expand Down
21 changes: 1 addition & 20 deletions docs/DevelopmentEnvironment.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ The majority of the environment needed to build **Selenium Foundation** is compr
| Version control | git version 2.27 |
| Command shell | GNU bash, version 4.4.23(1) |
| Gradle (build tool) | version 6.5 |
| Maven (build tool) | version 3.5.2 |
| Eclipse (IDE) | 2020-12 (4.18.0) |
| Maven Plug-In | m2e 1.17.1.20201207-1112 |
| BuildShip Plug-In | 3.1.5.v20210113-0904 |
| TestNG Plug-In | 7.3.0.202011271758 |

Expand All @@ -29,15 +27,9 @@ To build **Selenium Foundation**, you'll need a Java 8 software development kit:

The Gradle project file for **Selenium Foundation** includes a **selenium3Deps** sub-file. This reflects the past (and probable future) support for multiple versions of the Selenium API.

## Maven Configuration:

### Project Profiles

The Maven POM for **Selenium Foundation** defines an active-by-default **selenium3** profile. This reflects the past (and probable future) support for multiple versions of the Selenium API.

### JDK Toolchains

To build the **Selenium Foundation** project with **Maven**, you'll also need to add a `toolchain` specification to your system configuration:
To build the **Selenium Foundation** project, you'll also need to add a **Maven** `toolchain` specification to your system configuration. This configuration allows **Gradle** to auto-discover the JDK installations on your machine:

###### C:\\Users\\<username>\\.m2\\toolchains.xml
```xml
Expand All @@ -61,19 +53,8 @@ To build the **Selenium Foundation** project with **Maven**, you'll also need to
| Variable | Target |
|:---|:---|
| **`GRADLE_HOME`** | Root folder of Gradle installation |
| **`M2`** | Path to Maven `bin` folder
| **`M2_HOME`** | Root folder of Maven installation |
| **`M2_REPO`** | Root folder of Maven repository |
| **`JDK8_HOME`** | Root folder of JDK 8 installation |

## TestNG Eclipse Configuration

In the **Selenium Foundation** POM file, the configuration for the Maven Surefire plug-in declares an `argLine` property that specifies the `-javaagent` option. The declaration of this option isn't needed to run or debug **TestNG** tests and may cause test execution to fail.

To resolve this issue, disable the option to pass the `argLine` property to **TestNG** in your **Eclipse** preferences:

> Preferences > TestNG > Maven > ☐ argLine
## JUnit Run Configuration

The JUnit support provided by **Selenium Foundation** relies on [event notifications](JUnit4Support.md#outline-of-required-elements) published by **JUnit Foundation**. Notifications are enabled by a Java agent, which uses bytecode enhancement to install hooks on test and configuration methods.
Expand Down
2 changes: 1 addition & 1 deletion docs/LocalGridConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ In addition to providing a local Grid instance for running Selenium tests on you

To maximize flexibility, configurability, consistency, and control, the browser sessions dispensed by **Selenium Foundation** are provided by an instance of **Selenium Grid**. To use an existing Grid instance for session provisioning, specify its endpoint URL in the [**`HUB_HOST`** setting](ConfiguringProjectSettings.md#selenium-grid-configuration). By default, **Selenium Foundation** will launch a local Grid and acquire sessions from there.

The unit tests of this project acquire browser sessions from a local Grid instance that gets launched at the start of the test run and torn down when the run is complete. By default, the local Grid runs in "servlet container" mode, and only non-browser support feature tests are run. Profiles defined in the Gradle and Maven project files allow you to specify which browser to target with the corresponding unit tests. This aspect of the **Selenium Foundation** project provides a working example of how to configure for the local Grid feature, as detailed in the following sections.
The unit tests of this project acquire browser sessions from a local Grid instance that gets launched at the start of the test run and torn down when the run is complete. By default, the local Grid runs in "servlet container" mode, and only non-browser support feature tests are run. Profiles defined in the Gradle project file allows you to specify which browser to target with the corresponding unit tests. This aspect of the **Selenium Foundation** project provides a working example of how to configure for the local Grid feature, as detailed in the following sections.

### Specifying plug-ins via System property

Expand Down
103 changes: 0 additions & 103 deletions mvn-build.sh

This file was deleted.

3 changes: 0 additions & 3 deletions pom.properties

This file was deleted.

Loading

0 comments on commit c0b803e

Please sign in to comment.