click_and_upload

def click_and_upload(
    self,
    element_description: str,
    file_path_or_provider: Union(str, callable)
) -> bool:
element_description
string
required

Description of the element to click on the page that opens the operating system’s file upload dialog (e.g., “Upload button”, “Choose file button”).

file_path_or_provider
Union[str, callable]
required

The path to the file you want to upload or a callable that returns a file-like object.

return
bool

Whether the file was uploaded successfully.

Sample Usage

Let’s say you have a file called simplex-logo.svg in the current directory. You can upload it with a file path:

from simplex import Simplex

simplex = Simplex(api_key="your_api_key")
simplex.create_session()
simplex.goto("https://www.simplex.sh/upload-example.html")
simplex.click_and_upload("Click or drag and drop", "simplex-logo.svg")

or with a callable:

import os
from simplex import Simplex

simplex = Simplex(api_key="your_api_key")
simplex.create_session()
simplex.goto("https://www.simplex.sh/upload-example.html")

def get_file_from_disk():
    return open("simplex-logo.svg", 'rb')

simplex.click_and_upload(
    "Click or drag and drop",
    lambda: get_file_from_disk()
)