最简单的Web Monkey 测试范例

简介: 最简单的Web Monkey 测试范例

大家好,我是阿萨,昨天学习了随机测试。立即搜索了随机测试的小工具。发现一个真正的傻瓜是的chrome 插件来做随机测试的。1. Chrome 插件欢迎从如下链接安装:https://chromeload.com/extension-41598-monkey-testing


安装完,开始应用,点开插件, 点Start 按钮。 随机测试就开始了。然后再点一下stop 就结束了。2. Playwright 可以测试输入框和按钮的小代码。使用Playwright 写一个小程序,随机生成小程序。


from playwright.sync_api import Playwright, sync_playwright
def fill_and_submit_form(page):    # Find all input fields on the page    input_fields = page.query_selector_all('input')
    # Fill in each input field with a unique value    for i, input_field in enumerate(input_fields):        input_field.fill(f'test{i}')
    # Find the submit button and click it    submit_button = page.query_selector('button[type="submit"]')    submit_button.click()
with sync_playwright() as playwright:    # Launch the browser and create a new page    browser = playwright.chromium.launch()    page = browser.new_page()
    # Navigate to the target web page    page.goto('https://example.com')
    # Fill in and submit the form on the page    fill_and_submit_form(page)
    # Close the browser    browser.close()


3. 可以测试Web页面所有组件的Monkey 测试工具使用如下代码可以测试所有页面上的随机组件。


import randomimport timefrom playwright.sync_api import Playwright, sync_playwright
def monkey_test_page(page, num_iterations):    # Define a list of action functions to perform on the page    actions = [click_random_element, fill_random_input, navigate_random_link]
    for i in range(num_iterations):        # Randomly choose an action function from the list        action = random.choice(actions)
        # Perform the chosen action on the page        action(page)
        # Wait for a random amount of time between actions        time.sleep(random.uniform(0.5, 1.5))
def click_random_element(page):    # Find all clickable elements on the page    clickable_elements = page.query_selector_all('a, button')
    # Randomly choose an element and click it    random_element = random.choice(clickable_elements)    random_element.click()
def fill_random_input(page):    # Find all input fields on the page    input_fields = page.query_selector_all('input[type="text"], input[type="password"], textarea')
    # Randomly choose an input field and fill it with a random string    random_input = random.choice(input_fields)    random_input.fill(''.join(random.choices('abcdefghijklmnopqrstuvwxyz', k=10)))
def navigate_random_link(page):    # Find all links on the page    links = page.query_selector_all('a')
    # Randomly choose a link and navigate to it    random_link = random.choice(links)    page.goto(random_link.get_attribute('href'))
with sync_playwright() as playwright:    # Launch the browser and create a new page    browser = playwright.chromium.launch()    page = browser.new_page()
    # Navigate to the target web page    page.goto('https://example.com')
    # Perform monkey testing on the page for 10 iterations    monkey_test_page(page, 10)
    # Close the browser    browser.close()


赶紧用起来吧,来测试下自己的Web应用。

相关文章
|
人工智能 安全 网络安全
Burp Suite Professional 2025.5 for macOS x64 & ARM64 - 领先的 Web 渗透测试软件
Burp Suite Professional 2025.5 for macOS x64 & ARM64 - 领先的 Web 渗透测试软件
558 3
|
7月前
|
Java 测试技术 网络安全
Burp Suite Professional 2025.10 for Windows x64 - 领先的 Web 渗透测试软件
Burp Suite Professional 2025.10 for Windows x64 - 领先的 Web 渗透测试软件
347 0
Burp Suite Professional 2025.10 for Windows x64 - 领先的 Web 渗透测试软件
|
7月前
|
安全 Linux iOS开发
Burp Suite Professional 2025.10 发布 - Web 应用安全、测试和扫描
Burp Suite Professional 2025.10 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
504 3
|
8月前
|
安全 NoSQL Shell
web渗透-SSRF漏洞及discuz论坛网站测试
SSRF(服务器端请求伪造)是一种安全漏洞,攻击者可诱使服务端发起任意请求,进而探测或攻击内网系统。常用于端口扫描、访问内部服务、读取本地文件等。常见防御包括限制协议、域名和IP,但可通过302跳转、短地址等方式绕过。
446 1
web渗透-SSRF漏洞及discuz论坛网站测试
|
安全 JavaScript 前端开发
AppSpider 7.5.020 发布 - Web 应用程序安全测试
AppSpider 7.5.020 for Windows - Web 应用程序安全测试
213 0
|
8月前
|
安全 Linux iOS开发
Burp Suite Professional 2025.9 发布 - Web 应用安全、测试和扫描
Burp Suite Professional 2025.9 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
653 0
Burp Suite Professional 2025.9 发布 - Web 应用安全、测试和扫描
|
10月前
|
安全 Linux iOS开发
Burp Suite Professional 2025.7 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
Burp Suite Professional 2025.7 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
788 0
Burp Suite Professional 2025.7 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
|
人工智能 安全 网络安全
Burp Suite Professional 2025.5 for Windows x64 - 领先的 Web 渗透测试软件
Burp Suite Professional 2025.5 for Windows x64 - 领先的 Web 渗透测试软件
590 4
Burp Suite Professional 2025.5 for Windows x64 - 领先的 Web 渗透测试软件
|
人工智能 自然语言处理 JavaScript
测试工程师要失业?Magnitude:开源AI Agent驱动的端到端测试框架,让Web测试更智能,自动完善测试用例!
Magnitude是一个基于视觉AI代理的开源端到端测试框架,通过自然语言构建测试用例,结合推理代理和视觉代理实现智能化的Web应用测试,支持本地运行和CI/CD集成。
2290 15
测试工程师要失业?Magnitude:开源AI Agent驱动的端到端测试框架,让Web测试更智能,自动完善测试用例!