Skip to content

Commit

Permalink
Retry clicking on delete confirmation popup
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry committed Nov 8, 2019
1 parent 8cc4dba commit bb9a83c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 19 deletions.
11 changes: 6 additions & 5 deletions tests/acceptance/customCommands/waitForElementEnabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
module.exports.command = function (
selector, locateStrategy = 'css selector', timeout = this.globals.waitForConditionTimeout
) {
let self = this
if (locateStrategy === 'xpath') {
this.useXpath()
self = this.useXpath()
} else if (locateStrategy === 'css selector') {
this.useCss()
self = this.useCss()
} else {
this.assert.fail('invalid locateStrategy')
return this.assert.fail('invalid locateStrategy')
}
this.expect.element(selector).enabled.before(timeout)
return this
self.expect.element(selector).enabled.before(timeout)
return self
}
55 changes: 43 additions & 12 deletions tests/acceptance/pageObjects/FilesPageElement/filesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,56 @@ module.exports = {
*
* @param {string} fileName
*/
deleteFile: function (fileName) {
return this.initAjaxCounters()
deleteFile: async function (fileName) {
await this
.waitForFileVisible(fileName)
.useXpath()
.performFileAction(fileName, 'delete')
.waitForElementEnabled(
this.elements.deleteFileConfirmationBtn.selector,
this.elements.deleteFileConfirmationBtn.locateStrategy
'css selector'
)
.click('@deleteFileConfirmationBtn')
.waitForCSSPropertyEquals(
{
selector: this.elements.deleteFileConfirmationDialog.selector,
locateStrategy: this.elements.deleteFileConfirmationBtn.locateStrategy,
property: 'display',
value: 'none'

const clickAction = function () {
return this.initAjaxCounters().click('@deleteFileConfirmationBtn')
.waitForOutstandingAjaxCalls()
.waitForAnimationToFinish()
.waitForElementNotVisible(
this.elements.deleteFileConfirmationDialog.selector,
this.api.globals.waitForConditionTimeout,
this.api.globals.waitForConditionPollInterval,
false,
function (result) {
console.log('waited for popup to disappear.')
}
)
}.bind(this)
await clickAction()

await this.isVisible(
{
selector: this.elements.deleteFileConfirmationBtn.selector,
locateStrategy: 'css selector',
suppressNotFoundErrors: true
},
async function (result) {
console.log(result)
if (result.status < 0) {
console.log('Looks like the button was not clicked. Retrying ....')
await clickAction()
}
)
.waitForOutstandingAjaxCalls()
}
)

return this.waitForCSSPropertyEquals(
{
selector: this.elements.deleteFileConfirmationDialog.selector,

locateStrategy: this.elements.deleteFileConfirmationBtn.locateStrategy,
property: 'display',
value: 'none'
}
)
.useCss()
},
/**
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/stepDefinitions/filesContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ When('the user deletes file/folder {string} using the webUI', function (element)
return client.page.FilesPageElement.filesList().deleteFile(element)
})

When('the user deletes the following elements using the webUI', function (table) {
When('the user deletes the following elements using the webUI', async function (table) {
for (const line of table.rows()) {
client.page.FilesPageElement.filesList().deleteFile(line[0])
await client.page.FilesPageElement.filesList().deleteFile(line[0])
deletedElements.push(line[0])
}
return client.page.filesPage()
Expand Down

0 comments on commit bb9a83c

Please sign in to comment.