
Disclaimer: The SAP Cloud SDK for Continuous Delivery and its features have been merged into project "Piper". Therefore we recommend to use the General Purpose Pipeline of project "Piper" instead of the SAP Cloud SDK pipeline. The reasoning for this change, as well as further information on how to adopt the General Purpose Pipeline are described in this guide. Although this blog post was written with the assumption the tests will be run in the SAP Cloud SDK pipeline they can also be run the same way in the General Purpose Pipeline of project "Piper"
e2e-tests/page_objects/login.js
. This page object reads the credentials from the configuration and enters them into the input fields. The selectors of these fields are specified in the elements section. These selectors are working for the standard app-router. For other forms, e.g. on Cloud Platform Neo, or customized forms these selectors need to be updated."use strict";
const loginCommands = {
loginWithForm: function () {
const user = this.api.globals.user;
const pass = this.api.globals.pass;
delete this.api.globals.user;
delete this.api.globals.pass;
this.waitForElementVisible("@usernameField")
.setValue("@usernameField", user);
this.waitForElementVisible("@passwordField")
.setValue("@passwordField", pass);
this.waitForElementVisible("@submitButton").click("@submitButton");
this.expect.element("@usernameField").to.not.be.present;
return this;
},
};
module.exports = {
url: function () {
return this.api.launchUrl;
},
elements: {
usernameField: "input[name=username]",
passwordField: "input[name=password]",
submitButton: "input[type=submit]"
},
commands: [loginCommands]
};
e2e-tests/cucumber.conf.js
which we created in step 13. The updated content looks as follows: {
const options = {
configFile: __dirname + "/nightwatch.conf.js",
env: argv.NIGHTWATCH_ENV || 'firefox'
}
await startWebDriver(options);
await createSession(options);
const loginPage = client.page.login();
await loginPage.navigate().loginWithForm(false);
});
AfterAll(async () => {
await closeSession();
await stopWebDriver();
setTimeout(() => {
reporter.generate({
theme: 'bootstrap',
jsonFile: reportsDirectory + "/cucumber_report.json",
output: reportsDirectory + "/cucumber_report.html",
reportSuiteAsScenarios: true,
launchReport: false
});
}, 0);
});
BeforeAll
block to log into the application.e2e-tests/nightwatch.conf.js
from step 13 looks as follows:
const chromedriver = require('chromedriver');
const geckodriver = require('geckodriver');
const argv = require("yargs").argv;
module.exports = {
output_folder: 's4hana_pipeline/reports/e2e',
page_objects_path: __dirname + '/page_objects',
silent: !process.env.NIGHTWATCH_VERBOSE,
test_settings: {
default: {
launch_url : argv.launchUrl,
webdriver: {
start_process: true,
port: 4444
},
globals: {
abortOnAssertionFailure : true,
retryAssertionTimeout: 10000,
waitForConditionTimeout: 10000,
asyncHookTimeout : 10000,
user: "${e2e_username}",
pass: "${e2e_password}"
},
screenshots: {
enabled: true,
path: 's4hana_pipeline/reports/e2e/screenshots'
}
},
chromeHeadless: {
webdriver: {
server_path: chromedriver.path,
cli_args: ['--port=4444']
},
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
chromeOptions: {
args: ['headless', 'window-size=1280,800', 'disable-gpu', 'no-sandbox']
}
}
},
chrome: {
webdriver: {
server_path: chromedriver.path,
cli_args: ['--port=4444']
},
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
chromeOptions: {
args: ['window-size=1280,900', 'disable-gpu', 'no-sandbox']
}
}
},
firefox: {
webdriver: {
server_path: geckodriver.path,
cli_args: ['--port', '4444', '--log', 'debug']
},
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
acceptSslCerts: true,
marionette: true
}
}
}
};
user
and pass
. ${e2e_username}
means that the value is taken from the environment variable e2e_username
.launchUrl
) should point to the app-router. In the Neo environment, it should point to the application because the user is redirected to the login form automatically.set
to do that. The final command looks as follows:set e2e_username=myUser
set e2e_password=myPassword
npm install
npm run ci-e2e -- --launchUrl=https://path/to/your/running/app-router
pipeline_config.yml
. In step 14 we learned that this file configures the behavior of the pipeline. To execute the E2E tests we have to add a section called endToEndTests
representing a stage in the section stages
. The final configuration is shown below.#Project Setup
general:
productiveBranch: 'master'
projectName: 'business-partner-manager'
#Stage Specific Configurations
stages:
endToEndTests:
appUrls:
- url: 'https://approuter-USERNAME.cfapps.eu10.hana.ondemand.com'
credentialId: e2e-test-user-cf
cfTargets:
- space: 'MySpaceName'
manifest: 'manifest-test.yml'
org: 'MyOrg'
appName: 'firstapp'
credentialsId: 'deployment-cf'
endToEndTests
consists of two sections. Before we can run the E2E tests, we first have to deploy our application to the SAP Cloud Platform. As for the productive deployment, we define a section called cfTargets
or neoTargets
to configure the deployment. Afterwards in appUrls
we define a list of urls and
credential ids specifying the launch url for the tests and the credentials used as username and password environment variables.launchUrl
to the test. The credentialsId is used to read the corresponding credentials from the credentials store in Jenkins. Thus, we have to create these credentials, as explained in step 14. The username and password is read from the credentials store and passed as environment variable to the test.npm ci-smoke
is used instead of npm ci-e2e
. Thus, we have to define this command in the file package.json
. To run the same tests you can just copy the configuration from the command ci-e2e
in the section scripts as shown below. To run a subset of the tests you can use tags. "scripts": {
"ci-e2e": "cucumber-js e2e-tests/features --require e2e-tests/cucumber.conf.js --require e2e-tests/steps --format json:s4hana_pipeline/reports/e2e/cucumber_report.json",
"ci-smoke": "cucumber-js e2e-tests/features --require e2e-tests/cucumber.conf.js --require e2e-tests/steps --format json:s4hana_pipeline/reports/e2e/cucumber_report.json"
},
productiveDeployment
in the file pipeline_config.yml
has the same structure as the stage endToEndTests
:#Project Setup
general:
productiveBranch: 'master'
projectName: 'business-partner-manager'
#Stage Specific Configurations
stages:
productionDeployment:
appUrls:
- url: 'https://approuter-USERNAME.cfapps.eu10.hana.ondemand.com'
credentialId: e2e-test-user-cf
cfTargets:
- space: 'MySpaceNameProductive'
manifest: 'manifest.yml'
org: 'MyOrg'
appName: 'firstapp'
credentialsId: 'deployment-cf'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
18 | |
13 | |
11 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 |