pub struct Form { /* private fields */ }
Expand description
An HTML form on the current page.
Implementations§
Source§impl Form
impl Form
Source§impl Form
impl Form
Sourcepub async fn submit(&self) -> Result<(), CmdError>
pub async fn submit(&self) -> Result<(), CmdError>
Submit this form using the first available submit button.
false
is returned if no submit button was not found.
Sourcepub async fn submit_with(&self, button: Locator<'_>) -> Result<(), CmdError>
pub async fn submit_with(&self, button: Locator<'_>) -> Result<(), CmdError>
Submit this form using the button matched by the given selector.
false
is returned if a matching button was not found.
Sourcepub async fn submit_using(&self, button_label: &str) -> Result<(), CmdError>
pub async fn submit_using(&self, button_label: &str) -> Result<(), CmdError>
Submit this form using the form submit button with the given label (case-insensitive).
false
is returned if a matching button was not found.
Sourcepub async fn submit_direct(&self) -> Result<(), CmdError>
pub async fn submit_direct(&self) -> Result<(), CmdError>
Submit this form directly, without clicking any buttons.
This can be useful to bypass forms that perform various magic when the submit button is clicked, or that hijack click events altogether (yes, I’m looking at you online advertisement code).
Note that since no button is actually clicked, the name=value
pair for the submit button
will not be submitted. This can be circumvented by using submit_sneaky
instead.
Sourcepub async fn submit_sneaky(
&self,
field: &str,
value: &str,
) -> Result<(), CmdError>
pub async fn submit_sneaky( &self, field: &str, value: &str, ) -> Result<(), CmdError>
Submit this form directly, without clicking any buttons, and with an extra field.
Like submit_direct
, this method will submit this form without clicking a submit button.
However, it will also inject a hidden input element on the page that carries the given
field=value
mapping. This allows you to emulate the form data as it would have been if
the submit button was indeed clicked.