您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

64 行
1.7 KiB

  1. // ***********************************************
  2. // This example commands.js shows you how to
  3. // create various custom commands and overwrite
  4. // existing commands.
  5. //
  6. // For more comprehensive examples of custom
  7. // commands please read more here:
  8. // https://on.cypress.io/custom-commands
  9. // ***********************************************
  10. //
  11. //
  12. // -- This is a parent command --
  13. // Cypress.Commands.add("login", (email, password) => { ... });
  14. //
  15. //
  16. // -- This is a child command --
  17. // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... });
  18. //
  19. //
  20. // -- This is a dual command --
  21. // Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... });
  22. //
  23. //
  24. // -- This is will overwrite an existing command --
  25. // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... });
  26. Cypress.Commands.add('login', (email, password) => {
  27. cy.request({
  28. url: '/api/method/login',
  29. method: 'POST',
  30. body: {
  31. usr: email,
  32. pwd: password
  33. }
  34. });
  35. });
  36. Cypress.Commands.add('fill_field', (fieldname, value, fieldtype='Data') => {
  37. let selector = `.form-control[data-fieldname="${fieldname}"]`;
  38. if (fieldtype === 'Text Editor') {
  39. selector = `[data-fieldname="${fieldname}"] .ql-editor`;
  40. }
  41. cy.get(selector).as('input');
  42. if (fieldtype === 'Select') {
  43. return cy.get('@input').select(value);
  44. } else {
  45. return cy.get('@input').type(value);
  46. }
  47. });
  48. Cypress.Commands.add('awesomebar', (text) => {
  49. cy.get('#navbar-search').type(`${text}{downarrow}{enter}`, { delay: 100 });
  50. });
  51. Cypress.Commands.add('new_form', (doctype) => {
  52. cy.visit(`/desk#Form/${doctype}/New ${doctype} 1`);
  53. });
  54. Cypress.Commands.add('go_to_list', (doctype) => {
  55. cy.visit(`/desk#List/${doctype}/List`);
  56. });