Skip to content

browser.prompt#

Functions#

input_value(xpath, prompt_message, validate_input_regex=None, timeout=None) #

Prompt user for value through the terminal and insert this value into form field.

Parameters:

Name Type Description Default
xpath str

XPath of form field to insert value into.

required
prompt_message str

Message to prompt user with in the terminal.

required
validate_input_regex str | None

If provided, the input value will be validated against this regex.

None
timeout float | None

In seconds. Timeout to wait for element. If None, the global timeout setting is used (default 5 seconds).

None
Example

Basic usage:

browser.prompt.input_value("//xpath/to/input", "Input value:")

In context of a login form:

1
2
3
4
5
6
7
from browserist import Browser

with Browser() as browser:
    browser.open.url("https://example.com")
    browser.prompt.input_value("//xpath/to/input/username", "Input username:")
    browser.prompt.input_value("//xpath/to/input/password", "Input password:")
    browser.click.button("//xpath/to/button")

proceed_yes_or_no() #

Prompt user in the terminal whether to proceed or not.

Allowed Inputs Description
y, yes or press Enter/Return Proceed and return True.
n, no Do not proceed and return False.
Any other input Prompt user to try again.

Returns:

Type Description
bool

True if user wants to proceed, False otherwise.

Example

Basic usage:

browser.prompt.proceed_yes_or_no():

In context of a script:

1
2
3
4
5
6
7
8
from browserist import Browser

with Browser() as browser:
    browser.open.url("https://example.com")
    if browser.prompt.proceed_yes_or_no():
        browser.click.button("//xpath/to/button")
    else:
        print("Quitting...")