zenstruck / browser

A fluent interface for your Symfony functional tests.
MIT License
190 stars 18 forks source link

Selector API #77

Closed kbond closed 8 months ago

kbond commented 2 years ago

Fixes #15, Fixes #12. Fixes #37.

The idea is any method that accepts a $selector would allow string|Selector. Example:

$browser
    ->assertSeeElement(Selector::css('value'))
    ->assertSeeElement(Selector::id('value'))
    ->assertSeeElement(Selector::xpath('value'))
    ->assertSeeElement(Selector::link('value'))
    ->assertSeeElement(Selector::button('value'))
    ->assertSeeElement(Selector::field('value')) // form field

    /**
     * Plain string is an "auto" selector:
     * 1. Try css
     * 2. Try xpath
     * 3. Try id
     * 4. Try link
     * 5. Try button
     * 6. Try form field
     */
    ->assertSeeElement('value')
;