Skip to contents

If an element is an ancestor of a form, submits the form. Works by walking up the DOM, checking each ancestor element until the element is a <form> element, which it then submits. If such an element does not exist, an error is thrown.

Usage

elem_submit(x, js = FALSE, timeout = NULL)

Arguments

x

A selenider_element object.

js

Whether to submit the form using JavaScript.

timeout

How long to wait for the element to exist.

Value

x, invisibly.

See also

Examples

html <- "
<form>
<input type='submit'>
<p>Random text</p>
</form>
<a>Random link</a>
"

session <- minimal_selenider_session(html)

elem_submit(s("input"))
elem_submit(s("p"))

# Won't work since the element doesn't have a form ancestor
try(elem_submit(s("a"), timeout = 0.5))