Skip to content

Commit

Permalink
try to get collaborator role using both button and span selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
saw-jan committed May 31, 2022
1 parent a86b5f0 commit f28e192
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module.exports = {
if (subSelectors === null) {
subSelectors = {
displayName: this.elements.collaboratorInformationSubName,
role: this.elements.collaboratorInformationSubRole,
role: this.elements.collaboratorInformationSubRoleBtn,
additionalInfo: this.elements.collaboratorInformationSubAdditionalInfo,
shareType: this.elements.collaboratorShareType
}
Expand All @@ -142,16 +142,15 @@ module.exports = {
const collaboratorResult = {}
for (const attrName in subSelectors) {
let attrElementId = null
await this.api.elementIdElement(
collaboratorElementId,
'css selector',
subSelectors[attrName],
(result) => {
if (result.status !== -1) {
attrElementId = result.value.ELEMENT
}
}
)

if (attrName === 'role') {
attrElementId = await this.getCollaboratorRoleElemId(collaboratorElementId)
} else {
attrElementId = await this.getElementIdElement(
collaboratorElementId,
subSelectors[attrName]
)
}

if (attrElementId) {
await this.api.elementIdText(attrElementId, (text) => {
Expand All @@ -168,6 +167,38 @@ module.exports = {
results = await Promise.all(results)
return results
},
getCollaboratorRoleElemId: async function (parentElemId) {
let elementId = null

elementId = await this.getElementIdElement(
parentElemId,
this.elements.collaboratorInformationSubRoleBtn
)

if (!elementId) {
elementId = await this.getElementIdElement(
parentElemId,
this.elements.collaboratorInformationSubRole
)
}
return elementId
},
/**
*
* @param {string} parentElemId Web Element ID
* @param {string} selector valid css selector
*
* @returns {Promise.<string>} Web Element ID
*/
getElementIdElement: async function (parentElemId, selector) {
let elementId = null
await this.api.elementIdElement(parentElemId, 'css selector', selector, (result) => {
if (result.status !== -1) {
elementId = result.value.ELEMENT
}
})
return elementId
},
/**
*
* @returns {Promise.<string[]>} Array of user/group display names in share list
Expand Down Expand Up @@ -254,10 +285,14 @@ module.exports = {
// within collaboratorsListItem
selector: '.files-collaborators-collaborator-name'
},
collaboratorInformationSubRole: {
collaboratorInformationSubRoleBtn: {
// within collaboratorsListItem
selector: '.files-recipient-role-select-btn:first-child'
},
collaboratorInformationSubRole: {
// within collaboratorsListItem
selector: '.files-collaborators-collaborator-role'
},
collaboratorInformationSubAdditionalInfo: {
// within collaboratorsListItem
selector: '.files-collaborators-collaborator-additional-info'
Expand Down
23 changes: 14 additions & 9 deletions tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,20 @@ module.exports = {
* @param {string} collaborator
*/
getDisplayedPermission: async function (collaborator) {
await collaboratorDialog.expandShareRoleDropdown(collaborator)
await this.selectRole('Custom permissions')
// read the permissions from the checkboxes
const currentSharePermissions = await this.getSharePermissions()

// Hide role select dropdown
this.moveToElement('@customPermissionsDrop', -9, 0)
this.api.mouseButtonClick()
this.waitForElementNotPresent('@customPermissionsDrop', 1000)
let currentSharePermissions = {}
try {
await collaboratorDialog.expandShareRoleDropdown(collaborator)
await this.selectRole('Custom permissions')
// read the permissions from the checkboxes
currentSharePermissions = await this.getSharePermissions()

// Hide role select dropdown
await this.moveToElement('@customPermissionsDrop', -9, 0)
await this.api.mouseButtonClick()
await this.waitForElementNotPresent('@customPermissionsDrop', 1000)
} catch (e) {
console.info('Collaborator Role is not editable!')
}
return currentSharePermissions
},
/**
Expand Down

0 comments on commit f28e192

Please sign in to comment.