submitForm() public method

Submits the given form on the page, optionally with the given form values. Give the form fields values as an array. Skipped fields will be filled by their values from the page. You don't need to click the 'Submit' button afterwards. This command itself triggers the request to form's action. You can optionally specify what button's value to include in the request with the last parameter as an alternative to explicitly setting its value in the second parameter, as button values are not otherwise included in the request. Examples: php submitForm('#login', array('login' => 'davert', 'password' => '123456')); or $I->submitForm('#login', array('login' => 'davert', 'password' => '123456'), 'submitButtonName'); For example, given this sample "Sign Up" form: html
Login:
Password:
Do you agree to out terms?
Select pricing plan
You could write the following to submit it: php submitForm('#userForm', array('user' => array('login' => 'Davert', 'password' => '123456', 'agree' => true)), 'submitButton'); Note that "2" will be the submitted value for the "plan" field, as it is the selected option. You can also emulate a JavaScript submission by not specifying any buttons in the third parameter to submitForm. php submitForm('#userForm', array('user' => array('login' => 'Davert', 'password' => '123456', 'agree' => true)));
See also: Codeception\Lib\InnerBrowser::submitForm()
public submitForm ( $selector, $params, $button = null )
$selector
$params
$button
示例#1
0
 /**
  * Test for requirement 10 of student
  * @param  WebGuy $I [description]
  * @return [type]    [description]
  */
 public function urenInvullen(\WebGuy $I)
 {
     $I->amOnPage('/login');
     $I->see('Uren');
     $I->fillField('Username', 'student');
     $I->fillField('Password', 'student');
     $I->click('Login');
     $I->amOnPage('/student/1');
     $I->see('Student Page');
     $I->amOnPage('/student/1/uren/add');
     $I->submitForm('#ureninvullen', array('cursus' => 'SOP', 'onderdeel' => '1', 'date' => '19-01-2014', 'studielast', '1000'));
 }
示例#2
0
<?php

$I = new WebGuy($scenario);
$I->wantTo('ensure that contact works');
$I->amOnPage('?r=site/contact');
$I->see('Contact', 'h1');
$I->submitForm('#contact-form', []);
$I->see('Contact', 'h1');
$I->see('Name cannot be blank');
$I->see('Email cannot be blank');
$I->see('Subject cannot be blank');
$I->see('Body cannot be blank');
$I->see('The verification code is incorrect');
$I->submitForm('#contact-form', ['ContactForm[name]' => 'tester', 'ContactForm[email]' => 'tester.email', 'ContactForm[subject]' => 'test subject', 'ContactForm[body]' => 'test content', 'ContactForm[verifyCode]' => 'testme']);
$I->dontSee('Name cannot be blank', '.help-inline');
$I->see('Email is not a valid email address.');
$I->dontSee('Subject cannot be blank', '.help-inline');
$I->dontSee('Body cannot be blank', '.help-inline');
$I->dontSee('The verification code is incorrect', '.help-inline');
$I->submitForm('#contact-form', ['ContactForm[name]' => 'tester', 'ContactForm[email]' => '*****@*****.**', 'ContactForm[subject]' => 'test subject', 'ContactForm[body]' => 'test content', 'ContactForm[verifyCode]' => 'testme']);
$I->dontSeeElement('#contact-form');
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
示例#3
0
<?php

$I = new WebGuy($scenario);
$I->wantTo("Ensure the search function works");
$I->amOnPage('/');
$I->submitForm('#searchform', array('search' => 'pl'));
$I->see('PLAATJES');
示例#4
0
<?php

$I = new WebGuy($scenario);
$I->wantTo('ensure that login works');
$I->amOnPage('?r=site/login');
$I->see('Application', 'h1');
$I->submitForm('#login-form', array());
$I->dontSee('Logout (admin)');
$I->see('Username cannot be blank');
$I->see('Password cannot be blank');
$I->submitForm('#login-form', array('LoginForm[username]' => 'admin', 'LoginForm[password]' => 'wrong'));
$I->dontSee('Logout (admin)');
$I->see('Incorrect username or password');
$I->submitForm('#login-form', array('LoginForm[username]' => 'admin', 'LoginForm[password]' => 'admin'));
$I->see('Logout (admin)');
示例#5
0
文件: SanityCept.php 项目: ajb/rfpez
$I->fillField('vendor[address]', 'test');
$I->fillField('vendor[city]', 'test');
$I->fillField('vendor[zip]', '01234');
$I->click('Create Profile');
$I->see($email, 'a.dropdown-toggle');
$I->click('Bids');
$I->see('My Bids');
$I->click('Account Settings');
$I->see('My Account');
$I->click('Projects');
$I->see('Projects', 'h4');
$I->click('API for SBA.gov Dynamic Small Business Search');
$I->see('Bids due in', 'h5');
/* Ask a qusetion */
$question = 'This is my question ' . time();
$I->submitForm('#ask-question-form', array('project_id' => $I->grabValueFrom("input[name=project_id]"), 'question' => $question));
$I->moveBack();
$I->reloadPage();
$I->see($question, '.question');
$I->click("Bid on this Contract");
$I->see("New Bid", "h5");
$I->fillField("bid[approach]", "Approach.");
$I->fillField("bid[previous_work]", "Previous work.");
$I->fillField("bid[employee_details]", "Employee details.");
$I->click("Submit Bid");
$I->see("Thanks for submitting your bid.");
$I->see("Approach.", 'p');
$I->see("Previous work.", 'p');
$I->see("Employee details.", 'p');
$I->click("Sign Out");
/** Officer Sanity **/
示例#6
0
<?php

$I = new WebGuy($scenario);
$I->wantTo('Ensure the login system works');
$I->amOnPage('/login');
$I->see('Login');
$I->submitForm('#loginForm', array('_username' => 'admin', '_password' => 'admin'));
$I->see('Beheer');
示例#7
0
<?php

$I = new WebGuy($scenario);
$I->wantTo('ensure that contact works');
$I->amOnPage('?r=site/contact');
$I->see('Contact', 'h1');
$I->submitForm('#contact-form', array());
$I->see('Contact', 'h1');
$I->see('Name cannot be blank');
$I->see('Email cannot be blank');
$I->see('Subject cannot be blank');
$I->see('Body cannot be blank');
//$I->see('The verification code is incorrect');
$I->submitForm('#contact-form', array('ContactForm[name]' => 'tester', 'ContactForm[email]' => 'tester.email', 'ContactForm[subject]' => 'test subject', 'ContactForm[body]' => 'test content'));
//$I->dontSee('Name cannot be blank.');
$I->see('Email is not a valid email address.');
//$I->dontSee('Subject cannot be blank.');
//$I->dontSee('Body cannot be blank.');
//$I->dontSee('The verification code is incorrect');
$I->submitForm('#contact-form', array('ContactForm[name]' => 'tester', 'ContactForm[email]' => '*****@*****.**', 'ContactForm[subject]' => 'test subject', 'ContactForm[body]' => 'test content'));
$I->dontSeeElement('#contact-form');
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
示例#8
0
<?php

$I = new WebGuy($scenario);
$I->wantTo('ensure that login works');
$I->amOnPage('?r=site/login');
$I->see('Login', 'h1');
$I->submitForm('#login-form', []);
$I->dontSee('Logout (admin)');
$I->see('Username cannot be blank');
$I->see('Password cannot be blank');
$I->submitForm('#login-form', ['LoginForm[username]' => 'admin', 'LoginForm[password]' => 'wrong']);
$I->dontSee('Logout (admin)');
$I->see('Incorrect username or password');
$I->submitForm('#login-form', ['LoginForm[username]' => 'admin', 'LoginForm[password]' => 'admin']);
$I->see('Logout (admin)');