0
0
Laravelframework~10 mins

Browser testing with Dusk in Laravel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start a Dusk browser test session.

Laravel
public function testHomePage() {
    $this->browse(function (Browser $browser) {
        $browser->[1]('/');
    });
}
Drag options to blanks, or click blank then click option'
Aclick
BassertSee
Cvisit
Dtype
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'click' instead of 'visit' to open a page.
Trying to assert text before visiting a page.
2fill in blank
medium

Complete the code to check if the page contains the text 'Welcome'.

Laravel
$browser->[1]('Welcome');
Drag options to blanks, or click blank then click option'
Aclick
Btype
Cvisit
DassertSee
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'click' instead of 'assertSee' to check text.
Using 'type' which is for input fields.
3fill in blank
hard

Fix the error in the code to click a button with the selector '#submit'.

Laravel
$browser->[1]('#submit');
Drag options to blanks, or click blank then click option'
Avisit
Bclick
CassertSee
Dtype
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'visit' which navigates to a URL instead of clicking.
Using 'type' which inputs text instead of clicking.
4fill in blank
hard

Fill both blanks to type 'hello@example.com' into an input with name 'email' and then submit the form.

Laravel
$browser->[1]('input[name="email"]', 'hello@example.com')
        ->[2]('button[type="submit"]');
Drag options to blanks, or click blank then click option'
Atype
Bsubmit
Cclick
Dvisit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'submit' instead of 'click' on the submit button.
Using 'visit' instead of 'click' to submit.
5fill in blank
hard

Fill all three blanks to assert the current path is '/dashboard', then wait for an element with id 'profile', and finally assert the element contains the text 'User'.

Laravel
$browser->[1]('/dashboard')
        ->[2]('#profile')
        ->[3]('#profile', 'User');
Drag options to blanks, or click blank then click option'
AassertPathIs
BwaitFor
CassertSeeIn
Dvisit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'visit' instead of 'assertPathIs' to check URL.
Using 'assertSee' instead of 'assertSeeIn' for element-specific text.