Skip to content

Forms

Interactions with form tag.

Reading the element

Getting the right element class for the xpath

my_form = web.element('//*[id="myForm"]')
type(my_select)
Output
fastrpa.core.elements.FormElement

Try to get a FormElement

my_form = web.button('//*[id="myForm"]')
type(my_select)
Output
fastrpa.core.elements.FormElement

Reference

Get form method

my_form.method
Output
'POST'

Get form action

my_form.action
Output
'https://www.mysite.com/form'

Get form type

my_form.type
Output
'application/x-www-form-urlencoded'

Submit the form

my_form.submit()

Submit the form by clicking in a button

my_form.submit('//*[id="formSubmit"]')

Success conditions

Forms also accept success conditions to ensure your form was properly filled. If any condition fail, the form raises a FormException.

Set success by rediret to any url

my_form.set_success_condition(redirect_url='https:://.../success_page.html')

Set success by any element on the page

my_form.set_success_condition(elements_to_find=['//div[@id="success_message"]'])

Set success by any text on the page

my_form.set_success_condition(text_to_find=['Success!'])

Set success by all available conditions

1
2
3
4
my_form.set_success_condition(
    redirect_url='https:://.../success_page.html',
    elements_to_find=['//div[@id="success_message"]'],
    text_to_find=['Success!'])

Submit a form successfully

my_form.submit()

Fails a form submission

my_form.submit()
Output
Traceback (most recent call last):
    ...
FormException: The form submission got an error! Condition [redirect_url, https://...] not satisfied!