Selenium Webdriver for Erlang Quick Start
Selenium is the industry standard for automated testing of web applications. Together with Webdriver, a ‘remote control’ API for all major browsers, it enables you to create robust integration test for the browser.
The great people of QuviQ, creators of the unique Quickcheck test framework, created an Erlang Webdriver client implementation (Github repository).
It’s trivial to get started with the following steps:
Step 1: Add webdrv to the rebar.config of your project
Open rebar.config
in your favorite editor, and make sure webdrv is listed as dependency. I use a fork of the original repository that support rebar:
1 2 3 |
|
Step 2: Get and compile webdrv
Go to the root of your Erlang project and execute:
1
|
|
Step 3: Get & start the Google chromedriver
For this quick start we will be using the Google Chromedriver. Get the right package for your environment here. I’m now on a Mac, so:
1 2 3 |
|
The last line starts up the Chromedriver server and if all went well, you should get the following output:
1
|
|
Important! This server needs to be running during test execution.
Step 4: Your first Erlang webdrvr test!
Save the following module in src/random_org_test.erl
. In this test we open a page, fill in a form, submit the form, and check if an expected piece of text is indeed present in the response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
Step 5: Run the test
Run your test by opening up the Erlang shell..
1
|
|
..and execute the test function
1
|
|
You should see the Chrome browser opening in the background, quickly flashing some pages, closing, and on the Erlang shell the anticlamatic output ok
.
Further information
- Watch the Erlang Factory presentation by Hans Svensson from Quviq
- Erlang Webdrvr Github repository
- Selenium Webdriver documentation