SeleniumBase for Rust can upload test artifacts (screenshots, logs, PDFs) to Amazon S3, Azure Blob Storage, and Google Cloud Storage. Each backend is behind an optional Cargo feature so the default build stays lightweight.
These types are uploaders, not test hooks: call upload_file after a test, for
example on the screenshot a failure plugin saved. See
Test Plugins for the hooks.
What you will learn
- Which Cargo features enable each cloud backend.
- How to authenticate with AWS, Azure, and GCS.
- How to upload files from a test.
- How to run the included
cloud_uploadexample.
Enabling backends#
Add the features you need, in Cargo.toml or on the command line:
Providers#
Set the standard AWS environment variables:
MinIO and other S3-compatible stores are supported via AWS_ENDPOINT_URL:
Upload from a test:
Azure support uses a blob URL that already contains a SAS tokenShared access signature: a token in the URL query string that grants limited, time-bound access to a blob. with write permission:
Upload from a test:
Generate a SAS token with the Azure CLI:
GCS support uses an OAuth access token. The easiest way to obtain one is:
Upload from a test:
Running the example#
The example writes a small log file to latest_logs/ and only performs an
upload when the corresponding feature is enabled and its environment variables
are set. A backend that is compiled in but not configured is reported as
skipped, with the variables to set; the example fails only when an upload it
attempted fails. Besides the credentials described above, it reads the bucket
name from the environment, so nothing is hard-coded:
| Feature | Variables the example reads |
|---|---|
s3 | SB_S3_BUCKET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY; optional AWS_REGION and AWS_ENDPOINT_URL |
azure | AZURE_BLOB_URL |
gcp | SB_GCS_BUCKET, GCS_ACCESS_TOKEN |
Troubleshooting#
Upload function not found
Likely cause: Feature not enabled.
Fix: Add the matching feature in Cargo.toml.
S3 credentials error
Likely cause: Missing AWS_* variables.
Fix: Export AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
Azure SAS rejected
Likely cause: Token lacks write permission.
Fix: Regenerate with --permissions rw.
GCS token expired
Likely cause: GCS_ACCESS_TOKEN timed out.
Fix: Re-run gcloud auth print-access-token.