Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问clear审计通过

laravel-duskLaravel dusk 搜索

Agent Skill

laravel-dusk 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

776

周安装

33

GitHub Stars

31

下载量

272
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:laravel-dusk(Laravel dusk 搜索)
来源仓库:https://github.com/rawveg/skillsforge-marketplace
仓库路径:skills/laravel-dusk
安装命令:
npx skills add https://github.com/rawveg/skillsforge-marketplace --skill laravel-dusk
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/rawveg/skillsforge-marketplace --skill laravel-dusk

简介

用于 Laravel Dusk 测试相关信息的查找与检索。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中快速定位用例或问题。
  • 通过 GitHub 仓库安装,需确认权限与维护状态后再使用。
  • 建议结合原始 README 核验具体用法,避免误触发文件读写或命令执行。
  • 使用前请核实是否会涉及敏感信息或外部网络访问。

SKILL.md

Laravel Dusk Skill

Comprehensive assistance with Laravel Dusk browser automation and testing, providing expert guidance on writing expressive, easy-to-use browser tests for your Laravel applications.

When to Use This Skill

This skill should be triggered when:

  • Writing or debugging browser automation tests for Laravel
  • Testing user interfaces and JavaScript interactions
  • Implementing end-to-end (E2E) testing workflows
  • Setting up automated UI testing in Laravel applications
  • Working with form submissions, authentication flows, or page navigation tests
  • Configuring ChromeDriver or alternative browser drivers
  • Using the Page Object pattern for test organization
  • Testing Vue.js components or waiting for JavaScript events
  • Troubleshooting browser test failures or timing issues

Quick Reference

1. Basic Browser Test

public function testBasicExample(): void
{
    $this->browse(function (Browser $browser) {
        $browser->visit('/login')
            ->type('email', 'user@example.com')
            ->type('password', 'password')
            ->press('Login')
            ->assertPathIs('/home');
    });
}

2. Using Dusk Selectors (Recommended)

<!-- In your Blade template -->
<button dusk="login-button">Login</button>
<input dusk="email-input" name="email" />
// In your test - use @ prefix for dusk selectors
$browser->type('@email-input', 'user@example.com')
    ->click('@login-button');

3. Testing Multiple Browsers

public function testMultiUserInteraction(): void
{
    $this->browse(function (Browser $first, Browser $second) {
        $first->loginAs(User::find(1))
            ->visit('/home');

        $second->loginAs(User::find(2))
            ->visit('/home');
    });
}

4. Waiting for Elements

// Wait for element to appear
$browser->waitFor('.modal')
    ->assertSee('Confirmation Required');

// Wait for text to appear
$browser->waitForText('Hello World');

// Wait for JavaScript condition
$browser->waitUntil('App.data.servers.length > 0');

// Wait when element is available
$browser->whenAvailable('.modal', function (Browser $modal) {
    $modal->assertSee('Delete Account')
        ->press('OK');
});

5. Form Interactions

// Text input
$browser->type('email', 'user@example.com')
    ->append('notes', 'Additional text')
    ->clear('description');

// Dropdown selection
$browser->select('size', 'Large')
    ->select('categories', ['Art', 'Music']); // Multiple

// Checkboxes and radio buttons
$browser->check('terms')
    ->radio('gender', 'male');

// File upload
$browser->attach('photo', __DIR__.'/photos/profile.jpg');

6. Page Object Pattern

// Generate page object
// php artisan dusk:page Login

// app/tests/Browser/Pages/Login.php
class Login extends Page
{
    public function url(): string
    {
        return '/login';
    }

    public function elements(): array
    {
        return [
            '@email' => 'input[name=email]',
            '@password' => 'input[name=password]',
            '@submit' => 'button[type=submit]',
        ];
    }

    public function login(Browser $browser, $email, $password): void
    {
        $browser->type('@email', $email)
            ->type('@password', $password)
            ->press('@submit');
    }
}

// Use in test
$browser->visit(new Login)
    ->login('user@example.com', 'password')
    ->assertPathIs('/dashboard');

7. Browser Macros (Reusable Methods)

// In AppServiceProvider or DuskServiceProvider
use Laravel\Dusk\Browser;

Browser::macro('scrollToElement', function (string $element) {
    $this->script("$('html, body').animate({
        scrollTop: $('{$element}').offset().top
    }, 0);");

    return $this;
});

// Use in tests
$browser->scrollToElement('#footer')
    ->assertSee('Copyright 2024');

8. Database Management in Tests

use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTruncation;

class ExampleTest extends DuskTestCase
{
    // Option 1: Run migrations before each test (slower)
    use DatabaseMigrations;

    // Option 2: Truncate tables after first migration (faster)
    use DatabaseTruncation;

    // Exclude specific tables from truncation
    protected $exceptTables = ['migrations'];
}

9. JavaScript Execution

// Execute JavaScript
$browser->script('document.documentElement.scrollTop = 0');

// Get JavaScript return value
$path = $browser->script('return window.location.pathname');

// Wait for reload after action
$browser->waitForReload(function (Browser $browser) {
    $browser->press('Submit');
})->assertSee('Success');

10. Common Assertions

// Page assertions
$browser->assertPathIs('/dashboard')
    ->assertRouteIs('dashboard')
    ->assertTitle('Dashboard')
    ->assertSee('Welcome Back')
    ->assertDontSee('Error');

// Form assertions
$browser->assertInputValue('email', 'user@example.com')
    ->assertChecked('remember')
    ->assertSelected('role', 'admin')
    ->assertEnabled('submit-button');

// Element assertions
$browser->assertVisible('.success-message')
    ->assertMissing('.error-alert')
    ->assertPresent('button[type=submit]');

// Authentication assertions
$browser->assertAuthenticated()
    ->assertAuthenticatedAs($user);

Key Concepts

Dusk Selectors vs CSS Selectors

Dusk selectors (recommended) use HTML dusk attributes that won't change with UI updates:

  • More stable than CSS classes or IDs
  • Explicitly mark elements for testing
  • Use @ prefix in tests: $browser->click('@submit-button')
  • Add to HTML: <button dusk="submit-button">Submit</button>

CSS selectors are more brittle but sometimes necessary:

  • .class-name, #id, div > button
  • Can break when HTML structure changes
  • Use when you don't control the HTML

Waiting Strategies

Always wait explicitly rather than using arbitrary pauses:

  • waitFor('.selector') - Wait for element to exist
  • waitUntilMissing('.selector') - Wait for element to disappear
  • waitForText('text') - Wait for text to appear
  • waitUntil('condition') - Wait for JavaScript condition
  • whenAvailable('.selector', callback) - Run callback when available

Page Objects

Organize complex test logic into Page classes:

  • Define URL, assertions, and element selectors
  • Create reusable methods for page-specific actions
  • Improve test readability and maintainability
  • Generate with: php artisan dusk:page PageName

Browser Macros

Define reusable browser methods for common patterns:

  • Register in service provider's boot() method
  • Use across all tests
  • Chain like built-in methods
  • Example: scrolling, modal interactions, custom assertions

Reference Files

This skill includes comprehensive documentation in references/:

  • other.md - Complete Laravel Dusk documentation covering:

- Installation and configuration - ChromeDriver management - Test generation and execution - Browser interaction methods - Form handling and file uploads - Waiting strategies and assertions - Page Objects and Components patterns - CI/CD integration examples

Use the reference file when you need:

  • Detailed API documentation for specific methods
  • Complete list of available assertions (70+)
  • Configuration options for different environments
  • Advanced topics like iframes, JavaScript dialogs, or keyboard macros

Working with This Skill

For Beginners

  1. Start with basic tests: Use simple visit(), type(), press(), and assertSee() methods
  2. Use Dusk selectors: Add dusk attributes to your HTML for stable selectors
  3. Learn waiting: Always use waitFor() instead of pause() for reliable tests
  4. Run tests: Execute with php artisan dusk to see results

For Intermediate Users

  1. Implement Page Objects: Organize complex tests with the Page pattern
  2. Use database traits: Choose between DatabaseMigrations or DatabaseTruncation
  3. Create browser macros: Define reusable methods for common workflows
  4. Test authentication: Use loginAs() to bypass login screens
  5. Handle JavaScript: Use waitUntil() for dynamic content and AJAX

For Advanced Users

  1. Multi-browser testing: Test real-time features with multiple browsers
  2. Custom waiting logic: Use waitUsing() for complex conditions
  3. Component pattern: Create reusable components for shared UI elements
  4. CI/CD integration: Set up Dusk in GitHub Actions, Travis CI, or other platforms
  5. Alternative drivers: Configure Selenium Grid or other browsers beyond ChromeDriver

Navigation Tips

  • Quick examples: Check the Quick Reference section above for common patterns
  • Method documentation: See other.md for complete API reference
  • Assertions list: Reference file contains all 70+ available assertions
  • Configuration: Check reference file for environment setup and driver options
  • Best practices: Look for "Best Practices" section in reference documentation

Installation & Setup

# Install Laravel Dusk
composer require laravel/dusk --dev

# Run installation
php artisan dusk:install

# Update ChromeDriver
php artisan dusk:chrome-driver

# Make binaries executable (Unix)
chmod -R 0755 vendor/laravel/dusk/bin/

# Run tests
php artisan dusk

Common Commands

# Generate new test
php artisan dusk:make LoginTest

# Generate page object
php artisan dusk:page Dashboard

# Generate component
php artisan dusk:component Modal

# Run all tests
php artisan dusk

# Run specific test
php artisan dusk tests/Browser/LoginTest.php

# Run failed tests only
php artisan dusk:fails

# Run with filter
php artisan dusk --group=authentication

# Update ChromeDriver
php artisan dusk:chrome-driver --detect

Resources

Official Documentation

Common Patterns in Reference Files

The reference documentation includes:

  • 70+ assertion methods with descriptions
  • Complete form interaction API
  • Waiting strategies and timing best practices
  • Page Object pattern examples
  • Browser macro definitions
  • CI/CD configuration examples
  • Environment-specific test setup

Best Practices

  1. Use Dusk selectors (dusk attributes) instead of CSS classes for stability
  2. Wait explicitly with waitFor() methods instead of arbitrary pause()
  3. Organize with Page Objects for complex test scenarios
  4. Leverage database truncation for faster test execution
  5. Create browser macros for frequently repeated actions
  6. Scope selectors with with() or elsewhere() for specific page regions
  7. Test user behavior rather than implementation details
  8. Use authentication shortcuts like loginAs() to skip login flows
  9. Take screenshots with screenshot() for debugging failures
  10. Group related tests and use --group flag for targeted execution

Troubleshooting

Common Issues

ChromeDriver version mismatch:

php artisan dusk:chrome-driver --detect

Elements not found:

  • Use waitFor('.selector') before interacting
  • Check if element is in an iframe
  • Verify selector with browser dev tools

Tests failing randomly:

  • Replace pause() with explicit waits
  • Increase timeout: waitFor('.selector', 10)
  • Use waitUntil() for JavaScript conditions

Database state issues:

  • Use DatabaseTruncation trait
  • Reset data in setUp() method
  • Check for transactions in application code

Notes

  • Laravel Dusk uses ChromeDriver by default (no Selenium/JDK required)
  • Supports alternative browsers via Selenium WebDriver protocol
  • Tests are stored in tests/Browser directory
  • Page objects go in tests/Browser/Pages
  • Screenshots saved to tests/Browser/screenshots on failure
  • Console logs saved to tests/Browser/console for debugging

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

27.57%
按下载量换算75

Antigravity

25.59%
按下载量换算70

windsurf

18.02%
按下载量换算49

Codex

12.54%
按下载量换算34

OpenCode

7.92%
按下载量换算22

Gemini CLI

3.7%
按下载量换算10

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills