Skip to main content

Professional Selenium script development

To implement efficient web automation on Square Cloud, it’s essential to establish a proper development environment and follow configuration best practices.

Essential technical prerequisites

  • Python and pip: Make sure you have Python and pip installed on your system. If you don’t have them, download from the official Python website and the official Pip website.
  • Square Cloud Account: Create your account through the signup page, using your email address for registration.
  • Active plan: An active plan is necessary to ensure adequate resources for running Selenium applications. Check our available plans and choose the most suitable for your needs.

Selenium environment configuration

With Python and pip installed, proceed with creating the Selenium script. First, install the Selenium library:
Terminal
Next, create a Python file (for example, main.py) and add the following code to implement a basic Selenium script:
main.py

Dependency management with requirements.txt

The requirements.txt file is an essential component that lists all external libraries needed for your project. It’s crucial to include all dependencies used, excluding native Python libraries like random and datetime. This file should be included when submitting your application to Square Cloud.
requirements.txt

Chromium path configuration

In the implementation presented above, it’s not necessary to explicitly define the Chromium path, as the Selenium WebDriver can automatically locate the browser when installed in a standard system location. The ChromeDriver, specified with Service('/usr/bin/chromedriver'), has knowledge about where to locate the Chromium/Chrome executable.

Square Cloud architecture

On Square Cloud, Chromium is installed at /usr/bin/chromium, which is the standard system location. Therefore, the Selenium WebDriver can locate it automatically through the specified ChromeDriver. Thus, there’s no need to explicitly specify the Chromium path in the code, unless there are specific reasons to do so, such as custom installations or different environment configurations.

Square Cloud configuration file

Create a squarecloud.app file at the root of your project, next to main.py. It tells Square Cloud how to run your script:
squarecloud.app
  • MEMORY is the RAM in MB. Chromium is memory hungry, so give it at least 1024 MB and raise it if the application stops with LACK_OF_RAM.
  • AUTORESTART=true starts the script again if it crashes. See how auto restart works.
  • There is no SUBDOMAIN: the script doesn’t serve web pages.
Your ZIP holds main.py, requirements.txt and squarecloud.app.

Learn about: how to create the configuration file for Square Cloud.

The squarecloud.app file is an essential configuration file that will be used to configure your application on Square Cloud. It defines name, description, version, main file, among other fundamental configurations.

Project upload to Square Cloud

After preparing all project files, proceed with uploading to Square Cloud and host your application professionally.

Via dashboard

1

Access the Upload Page

Access the upload page and upload your project zip file.
2

Configure Your Environment

After uploading your zip, you will need to configure the name, main file or runtime environment and other settings for your project.
If you are uploading a web project, make sure to select “Web Publication” and set a subdomain to your project.
3

Deploy Your Project

Finally, click on the “Deploy” button to host your project on Square Cloud.
After deployment, you can monitor your project’s status and logs from the dashboard.
Uploading application to Square Cloud
4

Confirm Your App Is Live

Your first deploy usually takes less than a minute. In the dashboard, wait for your application status to show as running and check the logs for any startup errors.
If you deployed a website or API, open https://<your-subdomain>.squareweb.app in your browser: you should see your application responding. If you deployed a bot, send it a command to confirm it is online.
App not starting? See the Troubleshooting guide for the most common causes and fixes.

Via CLI

To use this method, your project needs a configuration file named squarecloud.app at its root. It tells Square Cloud how to run your application.

Configuration file guide

Learn how to create the squarecloud.app configuration file that defines your application’s environment.
1

Install the CLI

Install the Square Cloud CLI. If you already have it, run the same command to update it:
2

Log In

Run the command below. It opens your browser: approve the login there and the CLI is ready. There is no API key to copy. For scripts and CI, see CLI authentication.
3

Upload Your Project

From your project folder, run the command below. The CLI zips the current folder, leaving out what squarecloud.ignore lists, and uploads it:
To upload a zip you created yourself, pass it with --file:
4

Confirm Your App Is Live

Your first deploy usually takes less than a minute. Check your application status and logs directly from the terminal:
If you deployed a website or API, open https://<your-subdomain>.squareweb.app in your browser: you should see your application responding. If you deployed a bot, send it a command to confirm it is online.
App not starting? See the Troubleshooting guide for the most common causes and fixes.

Additional resources and documentation

For more detailed information about Selenium and its advanced tools, visit the official Selenium documentation. There you’ll find detailed technical guides, specialized tutorials, and complete API documentation to maximize the use of Selenium functionalities.

Next steps

App won't start

Fix LACK_OF_RAM, missing modules and other startup failures.

Python runtime

How Square Cloud runs Python applications.

Environment variables

Keep logins and API keys used by your automation out of your code.

Contact us

If you continue facing technical difficulties, our specialized support team is available to assist you. Contact us and we’ll be happy to help you resolve any issue: support quality is a big part of why developers rate Square Cloud 4.9/5 across 402 reviews on Google and Trustpilot.