WorklistPage.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. class WorklistPage {
  2. getTable() {
  3. return cy.get('table');
  4. }
  5. findTableAndDoubleClickFirstRow() {
  6. cy.get('table').within(() => {
  7. cy.get('tbody tr[data-testid="row-0"]')
  8. .scrollIntoView()
  9. .should('be.visible')
  10. .dblclick({ force: true });
  11. });
  12. }
  13. /**
  14. * 获取表头(排除第一列选择框)
  15. */
  16. getTableHeaders() {
  17. return cy.get('table thead th').not(':first');
  18. }
  19. /**
  20. * 获取所有表头
  21. */
  22. getAllTableHeaders() {
  23. return cy.get('table thead th');
  24. }
  25. /**
  26. * 获取特定列
  27. * @param columnName 列名文本
  28. */
  29. getColumn(columnName: string) {
  30. return cy.get('table thead th').contains(columnName);
  31. }
  32. /**
  33. * 验证列存在
  34. * @param columnName 列名文本
  35. */
  36. columnExists(columnName: string) {
  37. return this.getTableHeaders().contains(columnName).should('exist');
  38. }
  39. /**
  40. * 验证列不存在
  41. * @param columnName 列名文本
  42. */
  43. columnNotExists(columnName: string) {
  44. return this.getTableHeaders().contains(columnName).should('not.exist');
  45. }
  46. /**
  47. * 获取列宽
  48. * @param columnName 列名文本
  49. */
  50. getColumnWidth(columnName: string) {
  51. return cy
  52. .get('table thead th')
  53. .contains(columnName)
  54. .invoke('width');
  55. }
  56. /**
  57. * 验证列的顺序
  58. * @param expectedOrder 期望的列名顺序数组
  59. */
  60. verifyColumnOrder(expectedOrder: string[]) {
  61. this.getTableHeaders().then(($headers) => {
  62. expectedOrder.forEach((columnName, index) => {
  63. cy.wrap($headers.eq(index)).should('contain', columnName);
  64. });
  65. });
  66. }
  67. /**
  68. * 获取表头数量
  69. */
  70. getHeaderCount() {
  71. return this.getTableHeaders().its('length');
  72. }
  73. }
  74. export default WorklistPage;