Skip to content

Commit

Permalink
Check tooltitp (#477)
Browse files Browse the repository at this point in the history
* basic step check tooltip

* standart x-paths for then tooltip. Steptype update.

* check any param and role tooltip

* add Error Handling to then css and tool-tip

* corrected assert
  • Loading branch information
jonycoo authored Nov 10, 2023
1 parent 0177330 commit 3d27756
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
27 changes: 26 additions & 1 deletion backend/features/step_definitions/stepdefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,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)
Expand All @@ -856,7 +856,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)
Expand Down
13 changes: 12 additions & 1 deletion backend/src/database/stepTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 3d27756

Please sign in to comment.