Test Code: submit-a-form.js
This example shows how to submit a form with DOM API. To run code in the browser, the test uses a client function. The test runs against the TestCafe example page.
During the test, the t.typeText action types the developer name into the corresponding field. Then, the test calls the submitForm
client function that submits the form with HTMLFormElement.requestSubmit. Finally, the t.expect.contains assertion method verifies that the Thank you
page opens and displays the entered developer name.
- Test Structure:
- Fixture.page Method
- test Function
- Element Identification and Actions:
- t.typeText Method
- Assertion and Evaluation:
- t.expect.contains Method
- Custom Scripts:
- ClientFunction Object