Develop Function Compute by Running Selenium Java

By Yi Xian

This tutorial discusses how to develop Function Compute by running Selenium Java, but before we get down into it, let’s first take a look at several important concepts mentioned in this article.

Background Information

First, there’s Alibaba Cloud’s Function Compute, which is an event-driven service that allows users to write and upload code without having to manage server health or consider some other factors. Function Compute prepares and auto scales to the appropriate amount of computing resources necessary to run user code. The user only pays for the resources required to run their code.

Next, there’s Fun, which is a deployment tool for serverless applications. It helps you manage resources, such as Function Compute, API Gateway, and Log Service. You can use Fun to develop, build, and deploy resources by describing specified resources in the template.yml file.

Note: The techniques described in this article are applicable to Fun 2.10.2 or later.

Dependent Tools

This tutorial discusses how to develop Function Compute by running Selenium Java. The project outlined in this tutorial is developed on macOS but it also involves platform-independent tools, which are compatible with Linux and Windows. Before proceeding to this example, make sure that Docker, Fun, and Fcli are correctly installed, updated to the latest version and properly configured. You can download, update, and configure these tools with the instructions and resources on the pages linked here.

Fun and Fcli depend on Docker to simulate the local environment. MacOS users can use homebrew to install these tools:

Windows and Linux users can refer to Installation to learn how to install these tools. After the installation, don’t forget to first run fun config to initialize the configuration.

Note: If you have already installed Fun, make sure it is version 2.10.1 or higher.

Running Selenium Java

You can use the fun init command to easily initialize this template project to a local environment.

Then you can use the fun install command to install dependencies.

Text, you can conduct some local testing. To do so, you can use the ChromeDemo test code, whose segment content is as follows:

Next, you can trey the code locally by using the following command.

Then, deploy it using the fun deploy command.

Last, you can run it.

File size

Because the size of chromedriver and headless-chromium after the compression is very close to 50 MB and little space is left for the jar, a highly compressed version is also created. The file is 32.7 MB after compressed by using the Brotli algorithm which features a higher compression ratio. When running the project, use initializer for the decompression, which takes about 3.7s.


  1. Headless Chrome + Selenium Webdriver in AWS Lambda
  2. Running Selenium and Headless Chrome on AWS Lambda

Original Source

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store