
wdi5
💪wdi5
documentation site)npm i && npm start
in one terminal, then npm test
in another to have the test run)wdi5
had to adhere to that at config- and runtime. This was easy to solve: just a rename of the config- and test-file to a .cjs
extension to let the Node.js runtime know we're a CJS module. No coding changes required.wdi5
‘s standard mechanism of retrieving controls could be used in the tests.sap.m.Text
).const tile = await browser
.asControl({
selector: {
properties: {
text: "SAP Community Profile Picture Editor"
},
controlType: "sap.m.Text"
}
})
wdi5
's fluent async api until we reach the tile itself via .getParent().getParent()
.// get wdio element reference
const $tile = await tile.getWebElement()
// use wdio api
await $tile.click()
__tile0
might break the test eventually then.wdi5
’s excellent foundation, Webdriver.IO (wdio), playing in unison with wdi5
.wdi5
to retrieve the file uploader control.const uploader = await browser.asControl({
forceSelect: true,
selector: {
id: "fileToUpload",
viewName: "profilePic.view.App"
}
})
input
element. As per the WebDriver spec, this is the one DOM element capable of receiving a programmatic file upload.const $uploader = await uploader.getWebElement()
const $fileInput = await $uploader.$("input[type=file]")
await $fileInput.setValue(file)
wdi5
‘s api is used again to assert that the file was uploaded and to press the enhance/upload button.// assert the upload
const uploadedImage = await uploader.getValue()
expect(uploadedImage).toEqual(fileName)
// trigger pic enhancement
await browser
.asControl({
selector: {
id: "button",
viewName: "profilePic.view.App"
}
})
.firePress() // this will go away with wdi5 0.9.0 and replaced by .press()
// in wdio.conf.cjs
"goog:chromeOptions": {
prefs: {
directory_upgrade: true,
prompt_for_download: false,
"download.default_directory": join(__dirname, "test", "__assets__")
}
}
// wdi5
await browser
.asControl({
selector: {
id: "downloadButton",
viewName: "profilePic.view.App"
}
})
.firePress() // this will go away with wdi5 0.9.0 and replaced by .press()
const downloadedFile = join(__dirname, "__assets__", "image.png") // by the books, getting the image name dynamically would be a thing
// stat is from
// const { stat } = require("node:fs/promises")
expect(await (await stat(downloadedFile)).size).toBeGreaterThan(1)
wdi5
/wdio
by providing a respective flag to the browser config:// in wdio.conf.cjs
"goog:chromeOptions": {
args: process.env.DEBUG ? ["--auto-open-devtools-for-tabs"] : []
}
DEBUG
env var set, e.g. via DEBUG=true npm test
, then the debug pane opens.wdi5
, Webdriver.IO, Chrome and Node.js playing together nicely to test advanced functionality in a UI5 app.You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 |