preRequestScriptSnippets.js 605 B

123456789101112131415161718192021
  1. export default [
  2. {
  3. name: "Environment: Set an environment variable",
  4. script: `\n\n// Set an environment variable
  5. pw.env.set("variable", "value");`,
  6. },
  7. {
  8. name: "Environment: Set timestamp variable",
  9. script: `\n\n// Set timestamp variable
  10. const cuttentTime = Date.now();
  11. pw.env.set("timestamp", cuttentTime.toString());`,
  12. },
  13. {
  14. name: "Environment: Set random number variable",
  15. script: `\n\n// Set random number variable
  16. const min = 1
  17. const max = 1000
  18. const randomArbitrary = Math.random() * (max - min) + min
  19. pw.env.set("randomNumber", randomArbitrary.toString());`,
  20. },
  21. ]