wacat - 一款开源随机测试工具

想象一下,你离开电脑一会儿去拿一杯咖啡。与此同时,你的猫走过键盘,引发了一些混乱。

wacat 应用程序:

  • • 访问你的网页应用的根网址

  • • 随机访问应用中的每个链接

  • • 在表单中添加随机文本输入

  • • 从下拉菜单、复选框等中选择随机值

  • • 随机顺序点击每个按钮

此外,wacat 还可以:

  • • 检测浏览器与服务器之间的 HTTP 错误(例如 HTTP 500 错误)

  • • 检测浏览器控制台日志中的错误

  • • 从网页中检测错误字符串

    • • 你可以在参数文件中提供错误字符串

  • • 支持用户配置随机表单文本输入

  • • 可以从外部文件读取表单输入

  • • 可以仅测试链接,这可以用于应用程序的烟雾测试

  • • 支持某些身份验证场景

    • • 你可以在 JSON 文件中提供身份验证配置

  • • 支持配置不访问的页面

  • • 支持无头模式

  • • 支持配置页面下载等待时间和整个测试的超时值

  • • 支持在 CI 管道中运行

wacat 内部使用 Playwright[1] 工具。wacat 已经过测试,可在 Windows、Linux 和 Mac 上运行。

如果你发现了 bug 或需要某些特定功能,请创建一个新的 issue。

当前 wacat 版本为 1.1.2。请查看本页末尾以查看更改历史。

警告

请仅测试您自己的网页应用程序,或获得测试他人应用程序的许可。在未经许可的情况下测试他人应用程序的漏洞可能是违法的。

由于这是我的业余项目,一切皆有可能,最好密切关注 wacat 应用程序的行为,如果它访问了错误的页面,请使用 ctrl + c 停止。请注意,如果您的应用程序使用身份验证,而您的 wacat 身份验证配置不正确或 wacat 不适用于您的情况,那么您的帐户可能会被锁定或出现类似问题。此外,wacat 可能会扰乱您的应用程序数据库等。因此,最好仅在测试环境中进行测试。

安装

安装 Node.js

安装 Node.js 官方指引[2]

克隆 wacat 并安装

克隆 wacat,进入 wacat 目录并且运行:

npm install && npx playwright install --with-deps && npm run build && npm i -g

注意:由于 Playwright 工具是全局安装的,因此在运行前面的命令时可能会要求输入密码。

更新 wacat

更新 wacat 版本的指令:

git pull && npm install && npx playwright install --with-deps && npm run build && npm i -g

运行

Basic running

在 wacat 文件夹中运行以下命令:

wacat test <your url>

例如:

wacat test https://mikesmallhelp-test-application.vercel.app/

在 URL https://mikesmallhelp-test-application.vercel.app/ 中测试一个简单的应用程序。该应用程序包含以下页面:

首先,wacat 应用程序会打开 Chromium 浏览器并访问命令中提供的根 URL:

根页面不包含任何输入字段、下拉菜单等。wacat 简单地收集两个子页面的链接并访问它们。在每个子页面中,wacat 首先点击按钮,然后填写表单输入,选择下拉菜单项等,最后再次点击按钮。以下是您可以复制、粘贴并运行的命令。同样,您可以运行所有其他示例,并请随意使用我的测试应用程序。

wacat test https://mikesmallhelp-test-application.vercel.app/
 
  1. Testing in url: https://mikesmallhelp-test-application.vercel.app/. Please wait...

  2. Running 1 test using 1 worker

  3. [chromium] › test.spec.ts:41:1 › test an application

  4. In the page: https://mikesmallhelp-test-application.vercel.app/

  5. In the page: https://mikesmallhelp-test-application.vercel.app/working-page2

  6. Push the button #1

  7. Filling the #1 text input field a value: _k6AKNU3z"{=myqS.K

  8. The label is 'Your Date of Birth Here', so generating an appropriate random content for the input field

  9. Filling the #2 text input field a value: 16/09/2004

  10. The #1 drop-down list. Selecting the option #2

  11. Selecting the #1 checkbox

  12. The #1 radio button group. Selecting the radio button #3

  13. Filling the #1 email input field a value: pvcgigtju.nwntltbk@uqimkbwwiz.com

  14. Filling the #1 password input field a value: A#1!!a#!#AaA!A

  15. Filling the #1 search input field a value: SZOmqATkrV

  16. Filling the #1 url input field a value: https://nrebn.com

  17. Push the button #1

  18. In the page: https://mikesmallhelp-test-application.vercel.app/working-page

  19. Push the button #1

  20. Filling the #1 text input field a value: _k6AKNU3z"{=myqS.K

  21. The label is 'Your Date of Birth Here', so generating an appropriate random content for the input field

  22. Filling the #2 text input field a value: 16/09/2004

  23. The #1 drop-down list. Selecting the option #2

  24. Selecting the #1 checkbox

  25. The #1 radio button group. Selecting the radio button #2

  26. Filling the #1 email input field a value: uxxdxqcjhq.mhettm@ukyefgvdsk.gov

  27. Filling the #1 password input field a value: aa2B#1aA!##2A#!AaA

  28. Filling the #1 search input field a value: lSjsBVOzkhCC

  29. Filling the #1 url input field a value: https://vpo7ut.net

  30. Push the button #1

  31. 1 passed (24.3s)

请注意,输出包含“1 passed”,因此 wacat 没有在应用程序中发现任何错误。另外,请注意,每个页面的默认等待时间为 5000 毫秒。如果您想更改此时间,请使用 --wait 标志(详见后文)。

检测 HTTP 错误

wacat 可以检测浏览器和服务器之间的 HTTP 错误。例如,如果在下面的示例应用程序中点击按钮,会出现 HTTP 500 错误。

例如:

wacat test https://mikesmallhelp-test-application-http-500-error.vercel.app/
 
  1. Testing in url: https://mikesmallhelp-test-application-http-500-error.vercel.app/. Please wait...

  2. › Error:

  3. › Error occurred: Command failed: ROOT_URL='https://mikesmallhelp-test-application-http-500-error.vercel.app/' npx playwright test --project=chromium --headed

  4. › + stderr: + stdout:

  5. › Running 1 test using 1 worker

  6. [chromium] › test.spec.ts:40:1 › test an application

  7. › In the page: https://mikesmallhelp-test-application-http-500-error.vercel.app/

  8. In the page: https://mikesmallhelp-test-application-http-500-error.vercel.app/working-page

  9. Push the button #1

  10. Filling the #1 text input field a value: 4trK*edD

  11. The #1 drop-down list. Selecting the option #2

  12. Push the button #1

  13. In the page: https://mikesmallhelp-test-application-http-500-error.vercel.app/api-returns-http-500

  14. Push the button #1

  15. In the page: https://mikesmallhelp-test-application-http-500-error.vercel.app/api-returns-http-500: Request to https://mikesmallhelp-test-application-http-500-error.vercel.app/api/http-500 resulted

  16. › in status code 500

  17. In the page: https://mikesmallhelp-test-application-http-500-error.vercel.app/api-returns-http-500: Found an error message in the browser's console: Failed to load resource: the server responded

  18. › with a status of 500 ()

  19. In the page: https://mikesmallhelp-test-application-http-500-error.vercel.app/api-returns-http-500: Found an error message in the browser's console: Error fetching data: Error: Network response was

  20. › not ok

  21. › at r (https://mikesmallhelp-test-application-http-500-error.vercel.app/_next/static/chunks/pages/api-returns-http-500-d6a108dd102494f7.js:1:1402)

  22. › at async n (https://mikesmallhelp-test-application-http-500-error.vercel.app/_next/static/chunks/pages/api-returns-http-500-d6a108dd102494f7.js:1:735)

  23. 1) [chromium] › test.spec.ts:40:1 › test an application ──────────────────────────────────────────

  24. › AssertionError: In the page: https://mikesmallhelp-test-application-http-500-error.vercel.app/api-returns-http-500: Request to

  25. › https://mikesmallhelp-test-application-http-500-error.vercel.app/api/http-500 resulted in status code 500

  26. › 51 |

  27. › 52 | if (!bypassHttpErrors) {

  28. › > 53 | fail(message);

  29. › | ^

  30. › 54 | }

  31. › 55 | }

  32. › 56 | });

  33. › at Page.<anonymous> (/home/lenovo/projektit/wacat/e2e-tests/test.spec.ts:53:17)

  34. 1 failed

  35. › [chromium] › test.spec.ts:40:1 › test an application

因此,wacat 会检测到 HTTP 500 错误,打印错误日志,显示文本 "1 failed" 并停止执行。具体的错误信息是:

 
  1. AssertionError: In the page: https://mikesmallhelp-test-application-http-500-error.vercel.app/api-returns-http-500: Request to 

  2.  ›   https://mikesmallhelp-test-application-http-500-error.vercel.app/api/http-500 resulted in status code 500

如果您想绕过 HTTP 错误时停止执行的行为,请使用 --bypass-http-errors 标志。例如,以下命令:

wacat test --bypass-http-errors https://mikesmallhelp-test-application-http-500-error.vercel.app/

执行不会像上一个示例那样因 HTTP 500 错误而停止。wacat 会将 HTTP 500 错误打印到日志中,但执行会继续进行。

从目标应用程序的页面检测错误字符串

这是一个示例应用程序,其中一个子页面包含错误文本 "Error occurred!":

在我们的示例中,我们配置 wacat 检测到 "Error occurred!"。我们还希望检测到错误文本 "abc"。我们在 JSON 文件中进行如下配置:

 
  1. {

  2.     "errorTextsInPages": ["abc", "Error occurred!"]

  3. }

在 Windows 上运行命令(使用 --conf 标志传递 JSON 文件):

wacat test --conf example-files\configuration-error-texts.json https://mikesmallhelp-test-application-error-in-page.vercel.app

在 Linux 和 Mac上运行命令:

wacat test --conf example-files/configuration-error-texts.json https://mikesmallhelp-test-application-error-in-page.vercel.app

命令的输出是:

 
  1. Testing in url: https://mikesmallhelp-test-application-error-in-page.vercel.app. Please wait...

  2. › Error:

  3. › Error occurred: Command failed: ROOT_URL='https://mikesmallhelp-test-application-error-in-page.vercel.app' CONFIGURATION_FILE_PATH=example-files/configuration-error-texts.json WAIT=2000 npx

  4. › playwright test --project=chromium --headed

  5. › + stderr: + stdout:

  6. › Running 1 test using 1 worker

  7. [chromium] › test.spec.ts:40:1 › test an application

  8. › In the page: https://mikesmallhelp-test-application-error-in-page.vercel.app/

  9. Check the page not contain the abc text

  10. Check the page not contain the Error occurred! text

  11. In the page: https://mikesmallhelp-test-application-error-in-page.vercel.app/error-text-in-page

  12. Check the page not contain the abc text

  13. Check the page not contain the Error occurred! text

  14. 1) [chromium] › test.spec.ts:40:1 › test an application ──────────────────────────────────────────

  15. › Error: expect(received).not.toContain(expected) // indexOf

  16. › Expected substring: not "Error occurred!"

  17. › Received string: "Test page - error-text-in-pageError occurred!{\"props\":{\"pageProps\":{}},\"page\":\"/error-text-in-page\",\"query\":{},\"buildId\":\"MVBwm9bMplVdAQ-ZjLXZ5\",\"nextExp

  18. › ort\":true,\"autoExport\":true,\"isFallback\":false,\"scriptLoader\":[]}"

  19. › 150 | for (const errorText of configuration.errorTextsInPages) {

  20. › 151 | console.log(`Check the page not contain the ${errorText} text`);

  21. › > 152 | expect(content).not.toContain(errorText);

  22. › | ^

  23. › 153 | }

  24. › 154 | }

  25. › 155 |

  26. › at checkPageForErrors (/home/lenovo/projektit/wacat/e2e-tests/test.spec.ts:152:29)

  27. › at handlePage (/home/lenovo/projektit/wacat/e2e-tests/test.spec.ts:122:5)

  28. › at visitLinks (/home/lenovo/projektit/wacat/e2e-tests/test.spec.ts:398:13)

  29. › at handlePage (/home/lenovo/projektit/wacat/e2e-tests/test.spec.ts:132:5)

  30. › at /home/lenovo/projektit/wacat/e2e-tests/test.spec.ts:73:5

  31. 1 failed

  32. › [chromium] › test.spec.ts:40:1 › test an application

wacat 在一个子页面中检测到 "Error occurred!" 文本,报告错误并显示 "1 failed" 文本,执行停止。

检测浏览器控制台中的错误

这是一个示例应用程序,其中包含在浏览器控制台中的错误日志记录:

示例命令

wacat test https://mikesmallhelp-test-application-error-in-browser-console.vercel.app

执行停止在浏览器控制台中的错误日志记录处:

 
  1. Testing in url: https://mikesmallhelp-test-application-error-in-browser-console.vercel.app. Please wait...

  2. › Error:

  3. › Error occurred: Command failed: ROOT_URL='https://mikesmallhelp-test-application-error-in-browser-console.vercel.app' WAIT=2000 npx playwright test --project=chromium --headed

  4. › + stderr: + stdout:

  5. › Running 1 test using 1 worker

  6. [chromium] › test.spec.ts:40:1 › test an application

  7. › In the page: https://mikesmallhelp-test-application-error-in-browser-console.vercel.app/

  8. In the page: https://mikesmallhelp-test-application-error-in-browser-console.vercel.app/working-page

  9. Push the button #1

  10. Filling the #1 text input field a value: q52<<r`k`bZzP<Jua#53RAn)cKg0&K14

  11. The #1 drop-down list. Selecting the option #2

  12. Push the button #1

  13. In the page: https://mikesmallhelp-test-application-error-in-browser-console.vercel.app/error-in-browser-console: Found an error message in the browser's console: Hello! Something wrong!

  14. 1) [chromium] › test.spec.ts:40:1 › test an application ──────────────────────────────────────────

  15. › AssertionError: In the page: https://mikesmallhelp-test-application-error-in-browser-console.vercel.app/error-in-browser-console: Found an error message in the browser's console: Hello!

  16. › Something wrong!

  17. › 62 |

  18. › 63 | if (!bypassBrowserConsoleErrors && !bypassHttpErrors) {

  19. › > 64 | fail(message);

  20. › | ^

  21. › 65 | }

  22. › 66 | }

  23. › 67 | });

  24. › at Page.<anonymous> (/home/lenovo/projektit/wacat/e2e-tests/test.spec.ts:64:17)

  25. 1 failed

  26. › [chromium] › test.spec.ts:40:1 › test an application

wacat 打印消息 "Found an error message in the browser's console: Hello! Something wrong!" 并停止执行。

如果您想绕过此检查并继续执行,请使用 --bypass-browser-console-errors 标志。以下命令:

wacat test --bypass-browser-console-errors https://mikesmallhelp-test-application-error-in-browser-console.vercel.app

不会像上一个示例那样停止。wacat 会记录错误消息,但继续执行。

配置随机表单输入

通常,wacat 会生成随机的表单输入。默认情况下,长度在 1 到 60 个字符之间,并使用默认字符集。使用 --random-input-texts-min-length 标志指定最小长度,使用 --random-input-texts-max-length 标志指定最大长度。使用 --random-input-texts-charset 标志指定字符集。示例命令和输出如下:

wacat test --random-input-texts-min-length 1 --random-input-texts-max-length 3 --random-input-texts-charset ®©¥¬¿ https://mikesmallhelp-test-application.vercel.app/
 
  1. Testing in url: https://mikesmallhelp-test-application.vercel.app/. Please wait...

  2. Running 1 test using 1 worker

  3. [chromium] › test.spec.ts:41:1 › test an application

  4. In the page: https://mikesmallhelp-test-application.vercel.app/

  5. In the page: https://mikesmallhelp-test-application.vercel.app/working-page

  6. Push the button #1

  7. Filling the #1 text input field a value: ®

  8. Filling the #2 text input field a value: ®

  9. Filling the #3 text input field a value: ®

  10. Filling the #4 text input field a value: ®

  11. Filling the #5 text input field a value: ®

  12. Filling the #6 text input field a value: ®

  13. The #1 drop-down list. Selecting the option #2

  14. Selecting the #1 checkbox

  15. The #1 radio button group. Selecting the radio button #3

  16. Push the button #1

  17. In the page: https://mikesmallhelp-test-application.vercel.app/working-page2

  18. Push the button #1

  19. Filling the #1 text input field a value: ®

  20. Filling the #2 text input field a value: ®

  21. Filling the #3 text input field a value: ®

  22. Filling the #4 text input field a value: ®

  23. Filling the #5 text input field a value: ®

  24. Filling the #6 text input field a value: ®

  25. The #1 drop-down list. Selecting the option #2

  26. Selecting the #1 checkbox

  27. The #1 radio button group. Selecting the radio button #2

  28. Push the button #1

  29. 1 passed (54.0s)

在这个示例中,wacat 生成随机字符串 ®,长度在 1 到 3 个字符之间,字符来自指定的字符集 ®©¥¬¿

从文件读取输入字段文本

此外,还可以从文件中读取输入字段,例如从文件 example-files/input.texts,内容如下:

 
  1. xaxa

  2. ybyb

wacat 使用文件中的每个输入文本填充目标应用程序中的每个输入字段,除非发生错误或页面变化。对于本地文件,在 Windows 上运行的命令为:

wacat test --input-texts example-files\input-texts.txt https://mikesmallhelp-test-application.vercel.app/ 

在 Linux 和 Mac 上:

wacat test --input-texts example-files/input-texts.txt https://mikesmallhelp-test-application.vercel.app/ 

对于远程文件:

wacat test --input-texts https://raw.githubusercontent.com/mikesmallhelp/wacat/main/example-files/input-texts.txt https://mikesmallhelp-test-application.vercel.app/

所有的指令输出为:

 
  1. Testing in url: https://mikesmallhelp-test-application.vercel.app/. Please wait...

  2. Running 1 test using 1 worker

  3. [chromium] › test.spec.ts:41:1 › test an application

  4. In the page: https://mikesmallhelp-test-application.vercel.app/

  5. In the page: https://mikesmallhelp-test-application.vercel.app/working-page

  6. Push the button #1

  7. Filling the #1 text input field a value: xaxa

  8. Filling the #2 text input field a value: xaxa

  9. Filling the #3 text input field a value: xaxa

  10. Filling the #4 text input field a value: xaxa

  11. Filling the #5 text input field a value: xaxa

  12. Filling the #6 text input field a value: xaxa

  13. The #1 drop-down list. Selecting the option #2

  14. Selecting the #1 checkbox

  15. The #1 radio button group. Selecting the radio button #3

  16. Push the button #1

  17. Filling the #1 text input field a value: ybyb

  18. Filling the #2 text input field a value: ybyb

  19. Filling the #3 text input field a value: ybyb

  20. Filling the #4 text input field a value: ybyb

  21. Filling the #5 text input field a value: ybyb

  22. Filling the #6 text input field a value: ybyb

  23. The #1 drop-down list. Selecting the option #2

  24. Selecting the #1 checkbox

  25. The #1 radio button group. Selecting the radio button #1

  26. Push the button #1

  27. In the page: https://mikesmallhelp-test-application.vercel.app/working-page2

  28. Push the button #1

  29. Filling the #1 text input field a value: xaxa

  30. Filling the #2 text input field a value: xaxa

  31. Filling the #3 text input field a value: xaxa

  32. Filling the #4 text input field a value: xaxa

  33. Filling the #5 text input field a value: xaxa

  34. Filling the #6 text input field a value: xaxa

  35. The #1 drop-down list. Selecting the option #2

  36. Selecting the #1 checkbox

  37. The #1 radio button group. Selecting the radio button #1

  38. Push the button #1

  39. Filling the #1 text input field a value: ybyb

  40. Filling the #2 text input field a value: ybyb

  41. Filling the #3 text input field a value: ybyb

  42. Filling the #4 text input field a value: ybyb

  43. Filling the #5 text input field a value: ybyb

  44. Filling the #6 text input field a value: ybyb

  45. The #1 drop-down list. Selecting the option #2

  46. Selecting the #1 checkbox

  47. The #1 radio button group. Selecting the radio button #3

  48. Push the button #1

  49. 1 passed (1.1m)

在输出中,您可以看到使用了 input-texts.txt 文件中的值。您可以使用不同的输入文本文件进行测试,例如来自页面 https://github.com/0xspade/Combined-Wordlists?tab=readme-ov-file 的文件。当您使用大输入文本文件时,请使用 --timeout 参数(详见下文),并设置足够大的值。

仅测试链接

要仅测试应用程序中的链接,请使用 --only-links 标志。此时,wacat 会加载页面并检测 HTTP 错误,但不会填写输入字段等。示例命令和输出如下:

wacat test --only-links https://mikesmallhelp-test-application.vercel.app/
 
  1. Testing in url: https://mikesmallhelp-test-application.vercel.app/. Please wait...

  2. Running 1 test using 1 worker

  3. [chromium] › test.spec.ts:40:1 › test an application

  4. In the page: https://mikesmallhelp-test-application.vercel.app/

  5. In the page: https://mikesmallhelp-test-application.vercel.app/working-page

  6. In the page: https://mikesmallhelp-test-application.vercel.app/working-page2

  7. 1 passed (14.7s)

登录验证

这是一个带有简单身份验证的应用程序:

wacat 可以使用以下 JSON 文件对该应用程序进行身份验证:

 
  1. {

  2.     "authentication": {

  3.         "usernameLabel": "Username",

  4.         "usernameValue": "Mike",

  5.         "passwordLabel": "Password",

  6.         "passwordValue": "Smallhelp",

  7.         "loginButtonLabel": "Login"

  8.     }

  9. }

请注意,例如该应用程序包含 "Username" 标签,这个标签被放入 JSON 中 "usernameLabel" 属性的值中。用户名值为 "Mike",被放入 JSON 中 "usernameValue" 属性的值中。同样的逻辑适用于密码输入字段。应用程序有一个名为 "Login" 的按钮,被放入 JSON 中 "loginButtonLabel" 属性的值中。

在 Windows 上的示例运行命令为:

wacat test --conf example-files\configuration-authentication.json https://mikesmallhelp-test-application-simple-authentication.vercel.app/

在 Linux 和 Mac 运行:

wacat test --conf example-files/configuration-authentication.json https://mikesmallhelp-test-application-simple-authentication.vercel.app/

命令的输出为:

 
  1. Testing in url: https://mikesmallhelp-test-application-simple-authentication.vercel.app/. Please wait...

  2. Running 1 test using 1 worker

  3. [chromium] › test.spec.ts:40:1 › test an application

  4. Filled the username and the password. Pushed the authentication button

  5. In the page: https://mikesmallhelp-test-application-simple-authentication.vercel.app/

  6. In the page: https://mikesmallhelp-test-application-simple-authentication.vercel.app/working-page2

  7. Push the button #1

  8. Filling the #1 text input field a value: =_e6PF[J{u98&QI`DP

  9. The #1 drop-down list. Selecting the option #2

  10. Push the button #1

  11. In the page: https://mikesmallhelp-test-application-simple-authentication.vercel.app/working-page

  12. Push the button #1

  13. Filling the #1 text input field a value: =_e6PF[J{u98&QI`DP

  14. The #1 drop-down list. Selecting the option #2

  15. Push the button #1

  16.   1 passed (24.7s)

请注意输出中的文本 "Filled the username and the password. Pushed the authentication button",这意味着 wacat 已完成身份验证。

进行更复杂的身份验证

这是一个具有更复杂身份验证的应用程序:

wacat 可以使用以下 JSON 文件对该应用程序进行身份验证:

 
  1. {

  2.     "authentication": {

  3.         "beforeAuthenticationLinkTexts": [

  4.             "Please go to an application",

  5.             "Please login"

  6.         ],

  7.         "usernameLabel": "Username",

  8.         "usernameValue": "Mike",

  9.         "usernameButtonLabel": "Next",

  10.         "passwordLabel": "Password",

  11.         "passwordValue": "Smallhelp",

  12.         "loginButtonLabel": "Login"

  13.     }

  14. }

这个 JSON 比前一个示例更复杂。它包含 "beforeAuthenticationLinkTexts" 属性,其中包含 "Please go to an application" 和 "Please login" 链接文本,这些文本出现在身份验证页面之前的页面中。应用程序在输入用户名的页面中有一个 "Next" 按钮。"Next" 的值被放入 JSON 中 "usernameButtonLabel" 属性的值中。

在 Windows 上的示例运行命令为:

wacat test --conf example-files\configuration-complicated-authentication.json https://mikesmallhelp-test-application-more-complicated-authentication.vercel.app/

在 Linux 和 Mac 运行:

wacat test --conf example-files/configuration-complicated-authentication.json https://mikesmallhelp-test-application-more-complicated-authentication.vercel.app/

输出为:

 
  1. Testing in url: https://mikesmallhelp-test-application-more-complicated-authentication.vercel.app/. Please wait...

  2. Running 1 test using 1 worker

  3. [chromium] › test.spec.ts:40:1 › test an application

  4. Filled the username and the password. Pushed the authentication button

  5. In the page: https://mikesmallhelp-test-application-more-complicated-authentication.vercel.app/

  6. In the page: https://mikesmallhelp-test-application-more-complicated-authentication.vercel.app/working-page

  7. Push the button #1

  8. Filling the #1 text input field a value: Agc-QmUBS,Z]zx,~q*:ZNX*?L

  9. The #1 drop-down list. Selecting the option #2

  10. Push the button #1

  11. In the page: https://mikesmallhelp-test-application-more-complicated-authentication.vercel.app/working-page2

  12. Push the button #1

  13. Filling the #1 text input field a value: Agc-QmUBS,Z]zx,~q*:ZNX*?L

  14. The #1 drop-down list. Selecting the option #2

  15. Push the button #1

  16. In the page: https://mikesmallhelp-test-application-more-complicated-authentication.vercel.app/logout

  17.   1 passed (28.7s)

配置不访问的页面

wacat 设计为不超出您正在测试的主机范围。您还可以配置更多不访问的页面 URL。

查看前一个示例:

In the page: https://mikesmallhelp-test-application-more-complicated-authentication.vercel.app/logout

如果您不想进入登出页面,可以在 JSON 中添加 "notVisitLinkUrls" 属性。该属性包含不访问的 URL。示例 JSON 如下:

 
  1. {

  2.     "authentication": {

  3.         "beforeAuthenticationLinkTexts": [

  4.             "Please go to an application",

  5.             "Please login"

  6.         ],

  7.         "usernameLabel": "Username",

  8.         "usernameValue": "Mike",

  9.         "usernameButtonLabel": "Next",

  10.         "passwordLabel": "Password",

  11.         "passwordValue": "Smallhelp",

  12.         "loginButtonLabel": "Login"

  13.     },

  14.     "notVisitLinkUrls": [

  15.         "https://mikesmallhelp-test-application-more-complicated-authentication.vercel.app/logout"

  16.     ]

  17. }

在 Windows 上的示例运行命令为:

wacat test --conf example-files/configuration-complicated-authentication-with-not-visit-link-urls-remote.json https://mikesmallhelp-test-application-more-complicated-authentication.vercel.app/

在 Linux 和 Mac 上的运行命令为:

wacat test --conf example-files/configuration-complicated-authentication-with-not-visit-link-urls-remote.json https://mikesmallhelp-test-application-more-complicated-authentication.vercel.app/

命令输出为:

 
  1. Testing in url: https://mikesmallhelp-test-application-more-complicated-authentication.vercel.app/. Please wait...

  2. Running 1 test using 1 worker

  3. [chromium] › test.spec.ts:40:1 › test an application

  4. Filled the username and the password. Pushed the authentication button

  5. In the page: https://mikesmallhelp-test-application-more-complicated-authentication.vercel.app/

  6. In the page: https://mikesmallhelp-test-application-more-complicated-authentication.vercel.app/working-page2

  7. Push the button #1

  8. Filling the #1 text input field a value: R?nSk,UP(UBO*t'm1^a^7HIv

  9. The #1 drop-down list. Selecting the option #2

  10. Push the button #1

  11. In the page: https://mikesmallhelp-test-application-more-complicated-authentication.vercel.app/working-page

  12. Push the button #1

  13. Filling the #1 text input field a value: R?nSk,UP(UBO*t'm1^a^7HIv

  14. The #1 drop-down list. Selecting the option #2

  15. Push the button #1

  16.   1 passed (23.2s)

请注意,输出中不再有以下行:

In the page: https://mikesmallhelp-test-application-more-complicated-authentication.vercel.app/logout
以无头模式运行

使用 --headless 标志以无头模式(无浏览器)运行。示例命令如下:

wacat test --headless https://mikesmallhelp-test-application.vercel.app/
在 CI 管道中运行

wacat 可以在 CI 管道中使用 --headless 标志运行。

配置等待时间

默认情况下,wacat 每个页面下载等待时间为 5000 毫秒。使用 --wait 标志以毫秒为单位配置页面下载等待时间。2000 毫秒等待时间的示例命令如下:

wacat test --wait 2000 https://mikesmallhelp-test-application.vercel.app/

注意:wacat 内部使用 Playwright 工具。通常情况下,Playwright 测试可以等待一些特定的文本。但 wacat 不知道要等待什么文本,因此使用等待时间。

配置整个测试的超时时间

默认情况下,整个测试命令的超时时间为 120 秒。使用 --timeout 标志以秒为单位配置整个测试的超时时间。超时时间值至少为 1 秒。50 秒超时时间的示例命令如下:

wacat test --timeout 50 https://mikesmallhelp-test-application.vercel.app/

注意:Playwright 内部使用的是毫秒。所以如果在这个示例中发生超时,输出会类似于:

Test timeout of 50000ms exceeded.
Help 指令

To see all the flags, run the command:

wacat test --help
 
  1. Test any web application, for example: wacat test http://localhost:3000

  2. USAGE

  3.   $ wacat test URL [--bypass-browser-console-errors] [--bypass-http-errors] [--conf <value>] [--debug] [--headless] [--input-texts <value>] [--only-links] [--random-input-texts-charset

  4.     <value>] [--random-input-texts-max-length <value>] [--random-input-texts-min-length <value>] [--timeout <value>] [--wait <value>]

  5. ARGUMENTS

  6.   URL  Application url to test, for example: http://localhost:3000

  7. FLAGS

  8.   --bypass-browser-console-errors          Bypass the browser console's error messages

  9.   --bypass-http-errors                     Bypass the HTTP errors

  10.   --conf=<value>                           Path to the configuration file

  11.   --debug                                  Enable debug mode

  12.   --headless                               Headless mode

  13.   --input-texts=<value>                    Path to the input texts file

  14.   --only-links                             Test only links

  15.   --random-input-texts-charset=<value>     Random input texts character set

  16.   --random-input-texts-max-length=<value>  Random input texts max length

  17.   --random-input-texts-min-length=<value>  Random input texts min length

  18.   --timeout=<value>                        A whole test run timeout in seconds

  19.   --wait=<value>                           A wait in milliseconds to wait a page load

  20. DESCRIPTION

  21.   Test any web application, for example: wacat test http://localhost:3000

  22. EXAMPLES

  23.   $ wacat test http://localhost:3000

开发 wacat

使用技术

wacat 使用以下的一些技术:

  • • Typescript

  • • Bash script

  • • oclif, The Open CLI Framework

  • • Playwright

  • • Next.js for the test applications

开发指引

在 Linux 和 Mac 上,进行更改并运行

npm run test && npm run build && npm install -g && ./run-tests.sh

run-tests.sh 脚本会运行所有测试用例,并验证 wacat 是否正常工作。或者,只需将更改推送到代码库,让 GitHub Actions 运行测试。

在 Windows 上,进行更改并运行

npm run test && npm run build && npm install -g

对于 Windows,目前还没有像 ./run-tests.sh 这样的自动测试脚本。运行

run-manual-tests.bat

并从输出中验证一切是否正常。

贡献

我们热烈欢迎各种形式的贡献。请查看问题页面。如果发现 bug 或需要某个特定功能,请创建一个新的 issue。

请注意:如果您添加了新功能,请为其添加测试用例。请查看 run-tests.sh 文件。还请考虑添加单元测试。

Change history

1.1.0 16.4.2024
  • • can derive the text input type from the label and generates an appropriate random content for the input field

    • • supports derivation from different email and date labels

1.0.0 23.3.2024
  • • Windows support

  • • support for the most typical html input types like radio, email etc.

  • • more flags like --random-input-texts-charset

  • • bug fixes

  • • GitHub Actions tests for Mac

引用链接

[1] Playwright: https://playwright.dev/
[2] 安装 Node.js 官方指引: https://nodejs.org/en

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.xdnf.cn/news/1523154.html

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

使用Redis如何实现集群会话同步?

使用Redis如何实现集群会话同步&#xff1f; 1、为什么选择Redis&#xff1f;2、如何实现&#xff1f;1. 环境准备2. 配置Web服务器3. 测试与验证4. 监控与优化 &#x1f496;The Begin&#x1f496;点点关注&#xff0c;收藏不迷路&#x1f496; 在分布式Web应用中&#xff0c…

springboot高校实验室教学管理系统的设计和实现

基于springbootvue高校实验室教学管理系统的设计和实现(源码L文ppt)4-045 4 系统总体设计 此次高校实验室教学管理系统通过springboot框架。springboot适合快速构建Web应用。springboot将B/S设计模式中的视图分成了View模块和Template模块两部分&#xff0c;将动态的逻辑处理…

51单片机.之蜂鸣器振动播放歌曲

蜂鸣器发声是通过喇叭振动发声的&#xff0c;通电产生磁场&#xff0c;磁铁吸收&#xff0c;而振动。不断释放&#xff0c;吸收。 1、蜂鸣器发声&#xff0c;播放不同频率的声音逐渐变尖 #include<reg52.h>sbit BUZZ P1^6;unsigned char T0RH0; unsigned char T0RL0; v…

SpringCloud开发实战(二):通过RestTemplate实现远程调用

目录 SpringCloud开发实战&#xff08;一&#xff09;&#xff1a;搭建SpringCloud框架 RestTemplate介绍 RestTemplate 是 Spring 框架中的一个类&#xff0c;它用于促进 HTTP 请求的发送和接收&#xff0c;并且简化了与 RESTful 服务的交互。RestTemplate 提供了许多便利的方…

Redis Zset 类型:Score 属性在数据排序中的作用

Zset 有序集合 一 . zset 的引入二 . 常见命令2.1 zadd、zrange2.2 zcard2.3 zcount2.4 zrevrange、zrangebyscore2.5 zpopmax、zpopmin2.6 bzpopmax、bzpopmin2.7 zrank、zrevrank2.8 zscore2.9 zrem、zremrangebyrank、zremrangebyscore2.10 zincrby2.11 集合间操作交集 : zi…

【算法】PageRank

一、引言 PageRank是由谷歌创始人拉里佩奇和谢尔盖布林在斯坦福大学读研究生时发明的一种算法&#xff0c;用于衡量网页的重要性。它基于一个简单的假设&#xff1a;更重要的网页会有更多的链接指向它。 二、算法原理 PageRank算法的核心思想是&#xff0c;一个网页的重要性可以…

沸点 | LDBC 第18届 TUC 会议召开,专家孙宇熙受邀参加并发表演讲

图数据管理领域国际权威组织LDBC&#xff08;Linked Data Benchmark Council&#xff09;于8月30日至31日在广州举办了第18届LDBC TUC会议。作为图数据库领域的创新引领者&#xff0c;嬴图受邀参加此次盛会&#xff0c;国际高性能计算与存储系统专家、大数据专家、图专家及嬴图…

【从零开始学爬虫】采集58同城房源数据

本文以采集北京市58同城房源数据为例进行演示&#xff1a; l 采集网站 【场景描述】采集58同城房源数据。 【使用工具】前嗅ForeSpider数据采集系统 http://www.forenose.com/view/commodity/forespider.html 【入口网址】 https://bj.58.com/xiaoqu/?PGTID0d000000-000…

三、数组————相关概念详解

数组 前言一、数据理论基础二、数组常用操作2.1 初始化数组2.2 访问数组中的元素2.3 插入元素2.4 删除元素 三、数组扩展3.1 遍历数组3.2 数组扩容 总结1、数组的优点2、数组的不足 前言 在数据结构中&#xff0c;数组可以算得上最基本的数据结构。数组可以用于实现栈、队列、…

YoloV10改进策略:卷积篇|基于PConv的二次创新|附结构图|性能和精度得到大幅度提高(独家原创)

文章目录 摘要论文指导PConv在论文中的描述改进YoloV10的描述改进代码与结构图改进方法测试结果总结摘要 在PConv的基础上做了二次创新,创新后的模型不仅在精度和速度上有了质的提升,还可以支持Stride为2的降采样。 改进方法简单高效,需要发论文的同学不要错过! 论文指导…

机器学习实战篇——肿瘤良性/恶性分类器(二元逻辑回归)

机器学习之实战篇——肿瘤良性/恶性分类器&#xff08;二元逻辑回归&#xff09; 前言数据集和实验文件下载相关文章推荐实验过程导入相关模块数据预处理手写二元逻辑回归模型&#xff08;小批量梯度下降&#xff09;sklearn逻辑回归器 前言 实验中难免有许多缺陷和错误&#…

Mac M1安装Hive

一、下载解压Hive 1.官网地址 https://dlcdn.apache.org/hive/ 2.选择对应版本进行下载&#xff0c;这里我以3.1.3为例&#xff1b; 3.下载好后&#xff0c;进行解压&#xff0c;并重命名为hive-3.1.3&#xff0c;放到资源库目录下&#xff1b; 二、配置系统环境 1.打开~/…

Hack The Box-Infiltrator【更新中】

信息收集&端口利用 nmap -sSVC infiltrator.htbStarting Nmap 7.94SVN ( https://nmap.org ) at 2024-09-02 09:17 CST Nmap scan report for infiltrator.htb Host is up (0.61s latency). Not shown: 987 filtered tcp ports (no-response) PORT STATE SERVICE …

C++竞赛初阶L1-15-第六单元-多维数组(34~35课)551: T456501 计算矩阵边缘元素之和

题目内容 输入一个整数矩阵&#xff0c;计算位于矩阵边缘的元素之和。 所谓矩阵边缘的元素&#xff0c;就是第一行和最后一行的元素以及第一列和最后一列的元素。 输入格式 第 1 行包含两个整数&#xff0c;分别为行数 m 和列数 n&#xff0c;两个整数之间空格隔开。 第 2 …

【单调栈 】2289. 使数组按非递减顺序排列

本文涉及的基础知识点 单调栈分类、封装和总结 LeetCode2289. 使数组按非递减顺序排列 给你一个下标从 0 开始的整数数组 nums 。在一步操作中&#xff0c;移除所有满足 nums[i - 1] > nums[i] 的 nums[i] &#xff0c;其中 0 < i < nums.length 。 重复执行步骤&a…

Sobel算子,Scharr算子和Laplacian算子

图像边缘检测大幅度地减少了数据量&#xff0c;并且剔除了可以认为不相关的信息&#xff0c;保留了图像重要的结构属性。有许多方法用于边缘检测&#xff0c; 绝大部分可以划分为两类&#xff1a;基于搜索和基于零穿越。 基于搜索:通过寻找图像一阶导数中的最大值来检测边界&am…

4.1 数据分析-excel 基本操作

第四节&#xff1a;数据分析-excel 基本操作 课程目标 学会excel 基本操作 课程内容 数据伪造 产生一份招聘数据 import pandas as pd from faker import Faker import random import numpy as np# 创建一个Faker实例&#xff0c;用于生成假数据&#xff0c;指定中文本地…

c# 笔记 winform添加右键菜单,获取文件大小 ,多条件排序OrderBy、ThenBy,list<double>截取前5个

Winform右键菜单‌ 要在C# Winform应用程序中添加右键菜单&#xff0c;‌你可以按照以下步骤操作&#xff1a;‌ 1.‌创建菜单项‌ 在Form的构造函数或加载事件中&#xff0c;‌创建ContextMenuStrip控件的实例&#xff0c;‌并为其添加菜单项。‌ 2.‌绑定到控件‌ 将Con…

踩坑记录(序列化与反序列化)

问题描述 实体类中设定字段名称为 sValue和yValue 返回给前段后,变成了svalue,yvalue 字段设置 测试结果:与字段不符,匹配失败 解决方法 在字段上添加JsonProperty("字段名")注解

报告 | 以消费者为中心,消费品零售行业数字化建设持续深化

​2024年是“消费促进年”&#xff0c;国内消费市场稳步复苏。在消费需求多样化、国家政策的推动下&#xff0c;“数字化转型”仍是消费品零售行业的年度主题词&#xff0c;是品牌方获取核心竞争力的必要途径。消费品零售行业的数字化转型重心有所调整&#xff0c;从线上渠道布…