browser.combo#
Functions#
log_in(login_credentials, login_form, timeout=None)
#
Standardised combination of methods to log in.
Note
Most websites process login in either one or two steps. Use LoginForm1Step
when username and password are prompted on the same page. Use LoginForm2Steps
when username is prompted first, and then the option to input password appears later on the same or a separate page. The two-step variation is often to verify whether a user exists or not before password can be entered (or should be redirected to a registration page).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
login_credentials | LoginCredentials | Apply username and password here. | required |
login_form | LoginForm1Step | LoginForm2Steps | Add settings class. | required |
timeout | float | None | In seconds. Timeout to wait for element(s). If | None |
Returns:
Type | Description |
---|---|
bool | None | If |
Example
Or use succesfull handling of the login with a conditional if
statement by setting return_bool
to True
as parameter in the settings class:
Configuration Classes#
LoginCredentials#
Settings class for the login credentials of a user profile.
Note
Separated from the login form so that the multiple users/roles can use the same form.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username | str | Username, e.g. email. | required |
password | str | Password. | required |
LoginForm1Step#
Settings for login form page in 1 step where both username and password are displayed at once.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url | str | None | URL to login page. | None |
username_input_xpath | str | XPath for username input field. | required |
password_input_xpath | str | XPath for password input field. | required |
submit_button_xpath | str | XPath for submit button. | required |
post_login_wait_seconds | float | None | Minor grace time to ensure the login has completed. | None |
post_login_url_contains | str | None | Optionally await redirect to this URL as a user is typically redirected automatically to a new page or view after logging in. | None |
post_login_element_xpath | str | None | Upon successful login, optionally await this element to be loaded. | None |
return_bool | bool | If set to | False |
LoginForm2Steps#
Settings for login form page in 2 steps where username is prompted first, and once confirmed, then the password can be entered.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url | str | None | URL to login page. | None |
username_input_xpath | str | XPath for username input field. | required |
username_submit_button_xpath | str | XPath for username submit button. | required |
password_input_xpath | str | XPath for password input field. | required |
password_submit_button_xpath | str | XPath for password submit button. | required |
post_login_wait_seconds | float | None | Minor grace time to ensure the login has completed. | None |
post_login_url_contains | str | None | Optionally await redirect to this URL as a user is typically redirected automatically to a new page or view after logging in. | None |
post_login_element_xpath | str | None | Upon successful login, optionally await this element to be loaded. | None |
return_bool | bool | If set to | False |