WebFormManager

Added in version 2.40.

class WebFormManager(**properties: Any)

Superclasses: Object

Form manager of a WebPage in a ScriptWorld

Methods

class WebFormManager
input_element_auto_fill(element: Value, value: str) None

Set the value of an HTML input element as if it had been edited by the user, triggering a change event, and set it as filled automatically. If element is not an HTML input element this function does nothing.

Added in version 2.40.

Parameters:
  • element – a Value

  • value – the text to set

input_element_is_auto_filled(element: Value) bool

Get whether element is an HTML input element that has been filled automatically.

Added in version 2.40.

Parameters:

element – a Value

input_element_is_user_edited(element: Value) bool

Get whether element is an HTML text input element that has been edited by a user action.

Added in version 2.40.

Parameters:

element – a Value

Signals

class WebFormManager.signals
form_controls_associated(frame: Frame, elements: Sequence[Value]) None

Emitted after form elements (or form associated elements) are associated to frame. This is useful to implement form auto filling for web pages where form fields are added dynamically. This signal might be emitted multiple times for the same frame.

Note that this signal could be also emitted when form controls are moved between forms. In that case, the elements array carries the list of those elements which have moved.

Clients should take a reference to the members of the elements array if it is desired to keep them alive after the signal handler returns.

Added in version 2.40.

Parameters:
  • frame – a Frame

  • elements – a GPtrArray of Value with the list of forms in the page

will_send_submit_event(form: Value, source_frame: Frame, target_frame: Frame) None

This signal is emitted when the DOM submit event is about to be fired for form. JavaScript code may rely on the submit event to detect that the user has clicked on a submit button, and to possibly cancel the form submission before WebFormManager::will-submit-form signal is emitted. However, beware that, for historical reasons, the submit event is not emitted at all if the form submission is triggered by JavaScript. For these reasons, this signal may not be used to reliably detect whether a form will be submitted. Instead, use it to detect if a user has clicked on a form’s submit button even if JavaScript later cancels the form submission, or to read the values of the form’s fields even if JavaScript later clears certain fields before submitting. This may be needed, for example, to implement a robust browser password manager, as some misguided websites may use such techniques to attempt to thwart password managers.

Added in version 2.40.

Parameters:
  • form – the Value to be submitted, which will always correspond to an HTMLFormElement

  • source_frame – the Frame containing the form to be submitted

  • target_frame – the Frame containing the form’s target, which may be the same as source_frame if no target was specified

will_submit_form(form: Value, source_frame: Frame, target_frame: Frame) None

This signal is emitted when form will imminently be submitted. It can no longer be cancelled. This event always occurs immediately before a form is submitted to its target, so use this event to reliably detect when a form is submitted. This signal is emitted after WebFormManager::will-send-submit-event if that signal is emitted.

Added in version 2.40.

Parameters:
  • form – the Value to be submitted, which will always correspond to an HTMLFormElement

  • source_frame – the Frame containing the form to be submitted

  • target_frame – the Frame containing the form’s target, which may be the same as source_frame if no target was specified

Fields

class WebFormManager
parent