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

news2024/9/23 7:29:03

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

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.coloradmin.cn/o/2101376.html

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

相关文章

当下最火爆的外卖会员卡项目值得吗

外卖会员卡项目是现如今外卖行业的热门课题之一。随着人们生活水平的提高和生活节奏的加快&#xff0c;外卖已经成为了许多人日常生活中的重要组成部分。为了吸引更多的顾客和提升用户黏性&#xff0c;许多外卖平台纷纷推出了会员卡项目。下面就给大家讲讲这个项目值不值得 第一…

vue2使用qiankun框架笔记

vue2使用qiankun框架笔记&#xff08;更新中&#xff09; 前言1. 创建项目1.1 创建项目和选择预置1.2 记录项目结构和依赖 2. 使用qiankun框架&#xff08;让微应用如iframe般嵌入到主应用中&#xff09;2.1 主应用下载乾坤&#xff0c;注册微应用2.2 改造主应用&#xff0c;创…

springboot中根据id更新用户信息

根据查询到详情&#xff0c;进行回想到弹窗&#xff0c;然后修改信息&#xff0c;保存更新用户信息 实现效果 代码实现 controller代码 /*** 修改员工*/PutMappingpublic Result update(RequestBody Emp emp) {log.info("修改员工操作 {}", emp);empService.updat…

深度学习(六)-循环神经网络

标准CNN模型的不足 假设数据之间是独立的。标准CNN假设数据之间是独立的&#xff0c;所以在处理前 后依赖、序列问题&#xff08;如语音、文本、视频&#xff09;时就显得力不从心。这一类数 据&#xff08;如文本&#xff09;和图像数据差别非常大&#xff0c;最明显的差别莫…

深度孤立森林 Deep Isolation Forest论文翻译(上)

README 绝大部分是自己翻译自己手打的&#xff0c;少部分参考有道翻译&#xff0c;主要是想仔细再读一遍&#xff0c;顺便就打出来了。这篇论文内容比较多&#xff0c;有代码&#xff0c;原作者有github和知乎账号&#xff0c;感兴趣可以找一下。欢迎讨论和批评指正。 用于异…

设计模式及创建型模式-python版

1 架构模式与设计模式 架构模式搞层次的设计模式&#xff0c; 描述系统整体结构和组织方式&#xff0c;设计模式是针对某个问题的解决方案&#xff0c;是一种解决问题的思路。 2 设计模式的分类 2.1 创建型模式 单例模式&#xff0c;工厂方法模式&#xff0c;抽象工厂模式&…

无人机反制:无线电侦测设备技术详解

无人机反制技术中的低空安全综合管理平台&#xff0c;作为守护低空安全的重要工具&#xff0c;集成了多种先进的技术手段和管理功能&#xff0c;实现了对无人机等低空飞行器的全方位、无死角监控与反制。以下是对该技术平台的详细解析&#xff1a; 一、技术架构与核心功能 低…

HTB-bike(SSTI模版注入)

前言 大家好&#xff0c;我是qmx_07,今天给大家讲解bike靶场 渗透过程 信息搜集 服务器开放了 22 ssh 和 http80端口 Wappalyzer 介绍&#xff1a;Wappalyzer是一种浏览器扩展程序&#xff0c;用于识别正在访问的网站所使用的技术栈和工具&#xff0c;比如使用的web框架&…

紫光同创PDS自动构建

1.开发背景 随着开发进度的不断迭代&#xff0c;需要对代码实行管控&#xff0c;FPGA代码管控也很重要&#xff0c;这个篇章主要是对紫光同创 PDS 开发环境下实现代码自动构建功能 2.开发需求 设计实验&#xff1a; 1&#xff09;点击一个脚本自动编译工程 2&#xff09;工程…

Fréchet Inception Distance(FID)原理

原理概述&#xff1a; FID 的核心思想是通过比较真实图像和生成图像在 Inception 模型特征空间中的分布差异&#xff0c;来评估生成模型的性能。它假设从真实数据和生成数据中提取的特征都近似服从高斯分布。 具体步骤&#xff1a; 特征提取&#xff1a;使用预训练的 Incepti…

动态加载使用Appsflyer报错Attribution data for this AppsFlyer ID is not available

1. 使用动态classloader加载AF SDK 日志&#xff1a;不能获取到非自然量 2024-09-03 18:07:22.350 2114-2114 ddup com.pn.cal I 找到AssetManager 2024-09-03 18:07:22.350 2114-2114 ddup com.pn.cal …

免费分享:中国煤炭资源分布图

数据详情 中国煤炭资源分布图 数据属性 数据名称&#xff1a;中国煤炭资源分布图 空间位置&#xff1a;中国 ​ 下载方法 打开数字地球开放平台网站&#xff0c;需要先注册登录&#xff0c;登录完成后&#xff0c;选择服务与支持下的资源下载&#xff0c;搜索并点击进入本…

Python加载 TorchScript 格式的 ResNet18 模型分类该模型进行预测并输出预测的类别和置信度

首先加载预训练的 ResNet18 模型。将模型设置为评估模式&#xff0c;以确保特定层&#xff08;如 Dropout 和 BatchNorm&#xff09;在评估时具有确定性的行为。创建一个形状为 (1, 3, 224, 224) 的随机张量作为示例输入。使用 torch.jit.trace 函数追踪模型在给定示例输入上的…

渗透测试靶机----DC系列 DC-1

渗透测试靶机----DC系列 DC-1 开启靶机&#xff0c;依旧是登陆窗&#xff0c;平平无奇 扫描ip&#xff0c;扫描端口&#xff0c;服务等信息 可以看到这里存在80服务&#xff0c;访问看看 非常明显&#xff0c;这里存在一个Drupal 的cms 并且是一个登录框&#xff0c;思路打开 …

VMware Fusion 13.6 发布下载,新增功能概览

VMware Fusion 13.6 发布下载&#xff0c;新增功能概览 VMware Fusion 13.6 for Mac - 领先的免费桌面虚拟化软件 适用于基于 Intel 处理器和搭载 Apple 芯片的 Mac 的桌面虚拟化软件 请访问原文链接&#xff1a;https://sysin.org/blog/vmware-fusion-13/&#xff0c;查看最…

位运算专题——常见位运算位图的使用力扣实战应用

目录 1、常见位运算 2、算法应用【leetcode】 2.1 判断字符是否唯一【面试题 】 2.1.1 算法思想【位图】 2.1.2 算法代码 2.2 只出现一次的数字 III 2.2.1 算法思想 2.2.2 算法代码 2.3 丢失的数字 2.3.1 算法思想 2.3.2 算法代码 2.4 两整数之和 2.4.1 算法思想 2…

C语言之猜数字小游戏

哈喽&#xff0c;大家好&#xff01;我是冰淇淋加点糖。今天我们来用前面所学的知识来开发一个猜数字的小游戏&#xff0c;锻炼我们的编程能力和编程思维。 猜数字小游戏功能简介 1.随机生成一个1-100的数字。 2.玩家用户开始猜数字。 > 猜大了&#xff0c;提醒猜大了…

【爬虫软件】采集抖音博主的主页发布作品

这是我用python开发的抖音爬虫采集软件&#xff0c;可自动按博主抓取已发布视频。 软件界面截图&#xff1a; 爬取结果截图&#xff1a; 几点重要说明&#xff1a; 软件使用演示视频&#xff1a; https://www.bilibili.com/video/BV1Kb42187qf 完整讲解文章&#xff1a; ht…

虚幻5|技能栏UI优化(3)——优化技能UI并实现显示背景UI,实现技能界面设计,实现技能栏的删除和添加

实现技能栏添加&#xff1a;将技能界面里的技能拖到技能栏格子 一.调整&#xff0c;在拖出技能的时候&#xff0c;还会有边框 1.打开拖拽的技能格子UI 除了技能按钮&#xff0c;下面的子级都放到垂直框的子级&#xff0c;然后删除技能按钮 2.将垂直框替换成包裹框 你会发现有…

OS_线程

2024.07.01&#xff1a;操作系统线程学习笔记 第7节 线程 7.1 线程的基本概念7.1.1 单线程地址空间 vs 多线程地址空间 7.2 线程的状态与转换&#xff08;照搬进程设计&#xff09;7.2.1 线程的3种基本状态 7.3 线程管理中的数据结构7.3.1 线程的用户栈7.3.2 线程的内核栈 7.4 …