Skip to content

Commit 114122f

Browse files
committed
update html example
1 parent 217ef69 commit 114122f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

docs/Examples/html_form_examples.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ $scenario = $test->scenario('Login Form Test');
3232
// Get login page and extract CSRF token
3333
$scenario->step('Get Login Page')
3434
->get('https://example.com/login')
35-
->extractFromRegex('csrf_token', 'name="_token" value="(.+?)"')
35+
->extractFromHtml('csrf_token', 'input[name="_token"]', 'value')
3636
->validateStatus('page_load', 200);
3737

3838
// Submit login form
@@ -59,7 +59,7 @@ $scenario = $test->scenario('Registration Form');
5959
// Load registration page
6060
$scenario->step('Load Register Page')
6161
->get('https://example.com/register')
62-
->extractFromRegex('csrf_token', 'name="_token" value="(.+?)"')
62+
->extractFromHtml('csrf_token', 'input[name="_token"]', 'value')
6363
->validateStatus('page_load', 200);
6464

6565
// Submit registration with form data
@@ -94,13 +94,12 @@ $scenario = $test->scenario('Multi-Step Form');
9494
// Step 1: Personal Info
9595
$scenario->step('Personal Info')
9696
->get('https://example.com/form/step1')
97-
->extractFromRegex('form_token', 'name="form_token" value="(.+?)"')
97+
->extractFromHtml('form_token', 'input[name="_token"]', 'value')
9898
->validateStatus('step1_load', 200);
9999

100100
$scenario->step('Submit Step 1')
101-
->post('https://example.com/form/step1')
101+
->post('https://example.com/form/step1',''form_token=${form_token}&name=${name}&email=${email}'')
102102
->header('Content-Type', 'application/x-www-form-urlencoded')
103-
->setBody('form_token=${form_token}&name=${name}&email=${email}')
104103
->validateStatus('step1_success', 302)
105104
->extractFromCookie('session_id', 'session_id');
106105

@@ -111,9 +110,8 @@ $scenario->step('Address Info')
111110
->validateStatus('step2_load', 200);
112111

113112
$scenario->step('Submit Step 2')
114-
->post('https://example.com/form/step2')
113+
->post('https://example.com/form/step2', 'address=${address}&city=${city}&country=${country}')
115114
->header('Cookie', 'session_id=${session_id}')
116-
->setBody('address=${address}&city=${city}&country=${country}')
117115
->validateStatus('step2_success', 302);
118116

119117
// Run the test and get the result

0 commit comments

Comments
 (0)