Introduction
Selenium is a powerful tool for automating web browsers. This guide covers deploying Selenium scripts on Shard Cloud using Python.Creating Your Project
Ensure you have Python and pip installed.Installing Dependencies
Basic Selenium Script
Create amain.py file:
main.py
Requirements File
Create arequirements.txt:
requirements.txt
Chrome/Chromium Path
On Shard Cloud, Chromium is installed at/usr/bin/chromium and ChromeDriver at /usr/bin/chromedriver. The WebDriver can locate these automatically.
Shard Cloud Configuration
Create a.shardcloud file:
.shardcloud
Selenium applications typically require at least 512MB-1024MB of memory due to
the browser overhead.
Advanced Example: Web Scraping
scraper.py
Deploying
1
Prepare Your Files
Ensure you have: -
main.py (or your script) - requirements.txt -
.shardcloud2
Exclude Unnecessary Files
Remove:
__pycache__/, venv/, *.pyc3
Create ZIP Archive
Compress your project folder.
4
Upload to Shard Cloud
Go to Shard Cloud Dashboard and
upload.
Accessing Screenshots
Screenshots saved by your script can be downloaded from Shard Cloud’s file manager in the dashboard.Additional Resources
Troubleshooting
Chrome crashed
Chrome crashed
- Ensure you’re using headless mode - Add
--disable-dev-shm-usageflag - Increase memory allocation
Element not found
Element not found
- Use WebDriverWait for dynamic content - Verify the selector is correct - Take a screenshot to debug the page state
Out of memory
Out of memory
Close the driver after each task and increase the
MEMORY value in your
config.