Skip to main content

Page Object

Form

The FormKit page object component is available to help you write system specs for your forms.

Parameters

  • target (string | Capybara::Node::Element): The selector or node of the form.

Example

form = PageObjects::Components::FormKit.new(".my-form")
form = PageObjects::Components::FormKit.new(find(".my-form"))

submit

Submits the form

Example

form.submit

reset

Reset the form

Example

form.reset

has_an_alert?

Returns if the field is enabled or not.

Example

form.has_an_alert?("message")
expect(form).to have_an_alert("message")

Field

The field helper allows you to interact with a specific field of a form.

Parameters

  • name (string): The name of the field.

Example

field = form.field("foo")

value

Returns the value of the field.

Example

field.value
expect(field).to have_value("bar")

checked?

Returns if the control of a checkbox is checked or not.

Example

field.checked?
expect(field).to be_checked

unchecked?

Returns if the control of a checkbox is unchecked or not.

Example

field.unchecked?
expect(field).to be_unchecked

disabled?

Returns if the field is disabled or not.

Example

field.disabled?
expect(field).to be_disabled

enabled?

Returns if the field is enabled or not.

Example

field.enabled?
expect(field).to be_enabled

toggle

Allows toggling a field. Only available for: checkbox.

Example

field.toggle

fill_in

Allows filling a field with a given value. Only available for: input, text, code, and composer.

Example

field.fill_in("bar")

select

Allows selecting a specified value in a field. Only available for: select, icon, menu, radio-group, and question.

Example

field.select("bar")

accept

Allows accepting a field. Only available for: question.

Example

field.accept

refuse

Allows refusing a field. Only available for: question.

Example

field.refuse