listUsersPage.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. const util = require('util');
  2. module.exports = {
  3. url: function () {
  4. return this.api.launchUrl + 'user/list.php?leftmenu=users';
  5. },
  6. commands: [
  7. {
  8. listOfUsersDisplayed: async function (dataTable) {
  9. const usersList = dataTable.hashes();
  10. this.useXpath();
  11. for (const row of usersList) {
  12. let login = row['login'];
  13. let lastName = row['last name'];
  14. const userDetail = util.format(this.elements.userList.selector, login, lastName);
  15. await this.waitForElementVisible('@userRow')
  16. .waitForElementVisible(userDetail);
  17. }
  18. return this.useCss();
  19. },
  20. numberOfUsersDisplayed: async function (number) {
  21. const userCount = util.format(this.elements.numberOfUsers.selector, number);
  22. await this.useXpath()
  23. .waitForElementVisible(userCount);
  24. return this.useCss();
  25. }
  26. }
  27. ],
  28. elements: {
  29. userRow: {
  30. selector: '//table[contains(@class,"tagtable")]/tbody/tr[position()>2]',
  31. locateStrategy: 'xpath'
  32. },
  33. numberOfUsers: {
  34. selector: '//div[contains(@class, "titre inline-block") and contains(., "List of users")]/span[.="(%d)"]',
  35. locateStrategy: 'xpath'
  36. },
  37. userList: {
  38. selector: '//table[contains(@class,"tagtable")]/tbody/tr[position()>2]/td/a//span[normalize-space(@class="nopadding usertext")][.="%s"]/../../following-sibling::td[.="%s"]',
  39. locateStrategy: 'xpath'
  40. }
  41. }
  42. };