Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add create, delete book scenario #1

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
tmp
# Logs
logs
*.log
Expand Down
18 changes: 18 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"printWidth": 120,
"trailingComma": "none",
"tabWidth": 4,
"useTabs": false,
"semi": false,
"singleQuote": false,
"arrowParens": "always",
"endOfLine": "lf",
"overrides": [
{
"files": ["*.yaml", "*.yml", "*.json", "*.md"],
"options": {
"tabWidth": 2
}
}
]
}
12 changes: 12 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { configs } = require("@eslint/js")

let cfg = {
languageOptions: {
sourceType: "commonjs",
globals: {
browser: true
}
}
}

module.exports = Object.assign(cfg, configs.recommended)
155 changes: 155 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
const { wdi5 } = require("wdio-ui5-service")

async function goHome() {
await wdi5.goTo("#Shell-home")
}

async function pressTile(name) {
const control = await browser.asControl({
selector: {
controlType: "sap.m.GenericTile",
properties: {
header: name
}
}
})
await control.press()
}

async function searchFor(text) {
await browser
.asControl({
selector: {
controlType: "sap.m.SearchField",
interaction: {
idSuffix: "I"
}
}
})
.enterText(text)
}

async function performStandardAction(name) {
const control = await browser.asControl({
selector: {
controlType: "sap.m.Button",
interactable: true,
id: new RegExp(`.*::StandardAction::${name}$`)
}
})
await control.press()
}

async function setFieldValue(name, value) {
const control = await browser.asControl({
selector: {
controlType: "sap.m.Input",
interaction: "root",
labelFor: {
text: name
}
}
})
await control.setValue(value)
}

async function openValueHelpForField(name) {
const control = await browser.asControl({
selector: {
controlType: "sap.m.Input",
labelFor: {
text: name
}
}
})
await control.press()
}

async function _findTableWithTitle(title, controlType, opt = {}) {
const { searchOpenDialogs } = opt
return await browser.asControl({
selector: {
controlType,
searchOpenDialogs,
interaction: "root",
descendant: {
controlType: "sap.m.Title",
properties: {
text: {
regex: {
source: `^${title}`
}
}
}
}
}
})
}

async function chooseRowInValueHelpDialogTable(tableTitle, rowNumber) {
const table = await _findTableWithTitle(tableTitle, "sap.ui.table.Table", { searchOpenDialogs: true })
const id = (await table.getId()) + `-rows-row${rowNumber}-col0`
await tapOnId(id)
/* the following works but is too slow
const rows = await table.getAggregation('rows');
const cells = await rows[rowNumber].getAggregation('cells');
await cells[0].press()
*/
}

async function selectRowInTable(tableTitle, targetRow) {
const table = await _findTableWithTitle(tableTitle, "sap.m.Table")
const items = await table.getItems() // REVISIT potential drawback: if the table has growing turned off and at the same time many entries
const checkbox = await items[targetRow].getMultiSelectControl()
await checkbox.press()
}

async function getTableRowCount(tableTitle) {
const table = await _findTableWithTitle(tableTitle, "sap.m.Table")
const items = await table.getItems()
return items.length
}

async function navigateBack() {
const control = await browser.asControl({
selector: {
controlType: "sap.ushell.ui.shell.ShellHeadItem",
interactable: true,
id: "backBtn"
}
})
await control.press()
}

async function pressButtonInDialog(text) {
const control = await browser.asControl({
selector: {
controlType: "sap.m.Button",
searchOpenDialogs: true,
interactable: true,
properties: {
text
}
}
})
await control.press()
}

async function tapOnId(id) {
await browser.executeScript('$("#"+$.escapeSelector(arguments[0])).trigger("tap")', [id])
await browser.waitForUI5()
}

module.exports = {
goHome,
pressTile,
searchFor,
performStandardAction,
setFieldValue,
openValueHelpForField,
chooseRowInValueHelpDialogTable,
selectRowInTable,
navigateBack,
pressButtonInDialog,
getTableRowCount
}
Loading