# seleniumExecuteTests
## Description
Enables UI test execution with Selenium in a sidecar container.
The step executes a closure (see example below) connecting to a sidecar container with a Selenium Server.
When executing in a
* local Docker environment, please make sure to set Selenium host to **`selenium`** in your tests.
* Kubernetes environment, plese make sure to set Seleniums host to **`localhost`** in your tests.
!!! note "Proxy Environments"
If work in an environment containing a proxy, please make sure that `localhost`/`selenium` is added to your proxy exclusion list, e.g. via environment variable `NO_PROXY` & `no_proxy`. You can pass those via parameters `dockerEnvVars` and `sidecarEnvVars` directly to the containers if required.
## Prerequisites
none
## Example
```groovy
seleniumExecuteTests (script: this) {
git url: 'https://github.wdf.sap.corp/xxxxx/WebDriverIOTest.git'
sh '''npm install
node index.js'''
}
```
### Example test using WebdriverIO
Example based on http://webdriver.io/guide/getstarted/modes.html and http://webdriver.io/guide.html
#### Configuration for Local Docker Environment
```js
var webdriverio = require('webdriverio');
var options = {
host: 'selenium',
port: 4444,
desiredCapabilities: {
browserName: 'chrome'
}
};
```
#### Configuration for Kubernetes Environment
```js
var webdriverio = require('webdriverio');
var options = {
host: 'localhost',
port: 4444,
desiredCapabilities: {
browserName: 'chrome'
}
};
```
#### Test Code (index.js)
```js
// ToDo: add configuration from above
webdriverio
.remote(options)
.init()
.url('http://www.google.com')
.getTitle().then(function(title) {
console.log('Title was: ' + title);
})
.end()
.catch(function(err) {
console.log(err);
});
```
## Parameters
| parameter | mandatory | default | possible values |
| ----------|-----------|---------|-----------------|
|script|yes|||
|buildTool|no|`npm`|`maven`, `npm`|
|containerPortMappings|no|`[selenium/standalone-chrome:[[containerPort:4444, hostPort:4444]]]`||
|dockerEnvVars|no|||
|dockerImage|no|buildTool=`maven`: `maven:3.5-jdk-8`
buildTool=`npm`: `node:8-stretch`
||
|dockerName|no|buildTool=`maven`: `maven`
buildTool=`npm`: `npm`
||
|dockerWorkspace|no|buildTool=`maven`:
buildTool=`npm`: `/home/node`
||
|failOnError|no|`true`||
|gitBranch|no|||
|gitSshKeyCredentialsId|no|``||
|sidecarEnvVars|no|||
|sidecarImage|no|`selenium/standalone-chrome`||
|sidecarName|no|`selenium`||
|sidecarVolumeBind|no|`[/dev/shm:/dev/shm]`||
|stashContent|no|