diff --git a/backend/features/step_definitions/stepdefs.js b/backend/features/step_definitions/stepdefs.js index 281806180..b26cbae2b 100644 --- a/backend/features/step_definitions/stepdefs.js +++ b/backend/features/step_definitions/stepdefs.js @@ -843,7 +843,7 @@ Then('So the checkbox {string} is set to {string} [true OR false]', async functi Then('So on element {string} the css property {string} is {string}', async function cssIs(element, property, value) { const world = this; - const identifiers = [`//*[contains(text(),'${element}')]`, `//*[@id='${element}']`, `//*[@*='${element}']`, `//*[contains(@id, '${element}')]`, `${element}`]; + const identifiers = [`//*[contains(text(),'${element}')]`, `//*[@id='${element}']`, `//*[@*='${element}']`, `//*[contains(@*, '${element}')]`, `//*[contains(@id, '${element}')]`, `${element}`]; const promises = []; for (const idString of identifiers) promises.push(driver.wait(until.elementLocated(By.xpath(idString)), searchTimeout, `Timed out after ${searchTimeout} ms`, 100)); await Promise.any(promises) @@ -855,7 +855,32 @@ Then('So on element {string} the css property {string} is {string}', async funct const hex = `#${r}${g}${b}`; expect(value.toString()).to.equal(hex.toString(), `actual ${hex} does not match ${value}`); } else expect(value.toString()).to.equal(actual.toString(), `actual ${actual} does not match ${value}`); + }).catch(async (e) => { + await driver.takeScreenshot().then(async (buffer) => { + world.attach(buffer, 'image/png'); + }); + throw Error(e); + }); + await driver.sleep(100 + currentParameters.waitTime); +}); + +Then('So the element {string} has the tool-tip {string}', async function toolTipIs(element, value) { + const world = this; + const identifiers = [`//*[contains(text(),'${element}')]`, `//*[@id='${element}']`, `\\*[@*='${element} and @role=tooltip]`, `//*[contains(@*, '${element}')]`, `//*[@*='${element}']`, `//*[contains(@id, '${element}')]`, `${element}`]; + const promises = []; + for (const idString of identifiers) promises.push(driver.wait(until.elementLocated(By.xpath(idString)), searchTimeout, `Timed out after ${searchTimeout} ms`, 100)); + await Promise.any(promises) + .then(async (elem) => { + const actual = await elem.getAttribute('title'); + expect(actual).to.equal(value); + }).catch(async (e) => { + await driver.takeScreenshot().then(async (buffer) => { + world.attach(buffer, 'image/png'); + }); + if (Object.keys(e).length === 0) throw NotFoundError(`The Element ${element} could not be found (check tool-tip).`); + throw Error(e); }); + await driver.sleep(100 + currentParameters.waitTime); }); // Closes the webdriver (Browser) diff --git a/backend/src/database/stepTypes.js b/backend/src/database/stepTypes.js index 4443e919f..5884c7456 100644 --- a/backend/src/database/stepTypes.js +++ b/backend/src/database/stepTypes.js @@ -449,13 +449,24 @@ function stepDefs() { stepType: 'then', type: 'CSS-Value', pre: 'So on element', - mid: 'the css property', + mid: 'the css property ', post: 'is', values: [ '', '', '' ] + }, + { + id: 502, + stepType: 'then', + type: 'Tool-Tip', + pre: 'So the element', + mid: 'has the tool-tip ', + values: [ + '', + '' + ] }, { id: 3, stepType: 'then',