Smashtest • Generate tests fast
Smashtest is an open-source tool and language for rapidly generating tests.
Greatly speed up your web automated testing by writing tests in a tree-like format.
Trees represent how we think when we're testing.
They allow us to list all the permutations that branch off from any given point.
Multiple browsers and devices
Screenshots
Sample test
Open Chrome
Open Firefox
Open Safari
Navigate to STR('site.com')
Click STR('Sign In')
Type STR({username:}) into STR('username box')
STR({username}) is STR('joe')
STR({username}) is STR('bob')
STR({username}) is STR('mary')
Verify success
STR({username}) is STR('baduser')
Verify error
represents
Test Case 1 Test Case 2 Test Case 3
----------- ----------- -----------
Open Chrome Open Firefox Open Safari
Navigate to 'site.com' Navigate to 'site.com' Navigate to 'site.com'
Click 'Sign In' Click 'Sign In' Click 'Sign In'
Type 'joe' into 'username box' Type 'joe' into 'username box' Type 'joe' into 'username box'
Verify success Verify success Verify success
Test Case 4 Test Case 5 Test Case 6
----------- ----------- -----------
Open Chrome Open Firefox Open Safari
Navigate to 'site.com' Navigate to 'site.com' Navigate to 'site.com'
Click 'Sign In' Click 'Sign In' Click 'Sign In'
Type 'bob' into 'username box' Type 'bob' into 'username box' Type 'bob' into 'username box'
Verify success Verify success Verify success
Test Case 7 Test Case 8 Test Case 9
----------- ----------- -----------
Open Chrome Open Firefox Open Safari
Navigate to 'site.com' Navigate to 'site.com' Navigate to 'site.com'
Click 'Sign In' Click 'Sign In' Click 'Sign In'
Type 'mary' into 'username box' Type 'mary' into 'username box' Type 'mary' into 'username box'
Verify success Verify success Verify success
Test Case 10 Test Case 11 Test Case 12
------------ ------------ ------------
Open Chrome Open Firefox Open Safari
Navigate to 'site.com' Navigate to 'site.com' Navigate to 'site.com'
Click 'Sign In' Click 'Sign In' Click 'Sign In'
Type 'baduser' into 'username box' Type 'baduser' into 'username box' Type 'baduser' into 'username box'
Verify error Verify error Verify error
which represents
Test Case 1 Test Case 2 Test Case 3
----------- ----------- -----------
let driver = await new Builder().forBrowser('chrome').build(); let driver = await new Builder().forBrowser('firefox').build(); let driver = await new Builder().forBrowser('safari').build();
await driver.get('http://site.com'); await driver.get('http://site.com'); await driver.get('http://site.com');
let signInButton = await driver.findElement(By.id('#sign-in')); let signInButton = await driver.findElement(By.id('#sign-in')); let signInButton = await driver.findElement(By.id('#sign-in'));
await signInButton.click(); await signInButton.click(); await signInButton.click();
await driver.wait(until.elementLocated(By.id('#username-box')), 10000); await driver.wait(until.elementLocated(By.id('#username-box')), 10000); await driver.wait(until.elementLocated(By.id('#username-box')), 10000);
let usernameBox = await driver.findElement(By.id('#username-box')); let usernameBox = await driver.findElement(By.id('#username-box')); let usernameBox = await driver.findElement(By.id('#username-box'));
await usernameBox.sendKeys('joe'); await usernameBox.sendKeys('joe'); await usernameBox.sendKeys('joe');
await driver.wait(until.elementLocated(By.id('#success-element')), 10000); await driver.wait(until.elementLocated(By.id('#success-element')), 10000); await driver.wait(until.elementLocated(By.id('#success-element')), 10000);
Test Case 4 Test Case 5 Test Case 6
----------- ----------- -----------
let driver = await new Builder().forBrowser('chrome').build(); let driver = await new Builder().forBrowser('firefox').build(); let driver = await new Builder().forBrowser('safari').build();
await driver.get('http://site.com'); await driver.get('http://site.com'); await driver.get('http://site.com');
let signInButton = await driver.findElement(By.id('#sign-in')); let signInButton = await driver.findElement(By.id('#sign-in')); let signInButton = await driver.findElement(By.id('#sign-in'));
await signInButton.click(); await signInButton.click(); await signInButton.click();
await driver.wait(until.elementLocated(By.id('#username-box')), 10000); await driver.wait(until.elementLocated(By.id('#username-box')), 10000); await driver.wait(until.elementLocated(By.id('#username-box')), 10000);
let usernameBox = await driver.findElement(By.id('#username-box')); let usernameBox = await driver.findElement(By.id('#username-box')); let usernameBox = await driver.findElement(By.id('#username-box'));
await usernameBox.sendKeys('bob'); await usernameBox.sendKeys('bob'); await usernameBox.sendKeys('bob');
await driver.wait(until.elementLocated(By.id('#success-element')), 10000); await driver.wait(until.elementLocated(By.id('#success-element')), 10000); await driver.wait(until.elementLocated(By.id('#success-element')), 10000);
Test Case 7 Test Case 8 Test Case 9
----------- ----------- -----------
let driver = await new Builder().forBrowser('chrome').build(); let driver = await new Builder().forBrowser('firefox').build(); let driver = await new Builder().forBrowser('safari').build();
await driver.get('http://site.com'); await driver.get('http://site.com'); await driver.get('http://site.com');
let signInButton = await driver.findElement(By.id('#sign-in')); let signInButton = await driver.findElement(By.id('#sign-in')); let signInButton = await driver.findElement(By.id('#sign-in'));
await signInButton.click(); await signInButton.click(); await signInButton.click();
await driver.wait(until.elementLocated(By.id('#username-box')), 10000); await driver.wait(until.elementLocated(By.id('#username-box')), 10000); await driver.wait(until.elementLocated(By.id('#username-box')), 10000);
let usernameBox = await driver.findElement(By.id('#username-box')); let usernameBox = await driver.findElement(By.id('#username-box')); let usernameBox = await driver.findElement(By.id('#username-box'));
await usernameBox.sendKeys('mary'); await usernameBox.sendKeys('mary'); await usernameBox.sendKeys('mary');
await driver.wait(until.elementLocated(By.id('#success-element')), 10000); await driver.wait(until.elementLocated(By.id('#success-element')), 10000); await driver.wait(until.elementLocated(By.id('#success-element')), 10000);
Test Case 10 Test Case 11 Test Case 12
------------ ------------ ------------
let driver = await new Builder().forBrowser('chrome').build(); let driver = await new Builder().forBrowser('firefox').build(); let driver = await new Builder().forBrowser('safari').build();
await driver.get('http://site.com'); await driver.get('http://site.com'); await driver.get('http://site.com');
let signInButton = await driver.findElement(By.id('#sign-in')); let signInButton = await driver.findElement(By.id('#sign-in')); let signInButton = await driver.findElement(By.id('#sign-in'));
await signInButton.click(); await signInButton.click(); await signInButton.click();
await driver.wait(until.elementLocated(By.id('#username-box')), 10000); await driver.wait(until.elementLocated(By.id('#username-box')), 10000); await driver.wait(until.elementLocated(By.id('#username-box')), 10000);
let usernameBox = await driver.findElement(By.id('#username-box')); let usernameBox = await driver.findElement(By.id('#username-box')); let usernameBox = await driver.findElement(By.id('#username-box'));
await usernameBox.sendKeys('baduser'); await usernameBox.sendKeys('baduser'); await usernameBox.sendKeys('baduser');
await driver.wait(until.elementLocated(By.id('#error-element')), 10000); await driver.wait(until.elementLocated(By.id('#error-element')), 10000); await driver.wait(until.elementLocated(By.id('#error-element')), 10000);
Setup
1. Install NodeJS
Make sure you have NodeJS installed.
We recommend the LTS version.
Use node -v to check.
2. Install Selenium Webdriver (if you're doing web UI testing)
- Make sure all of the browsers you want to automate are installed
- Make sure you have Java installed. Use java -showversion to check.
- Choose one of the following options:
Option 1: Webdriver manager
Webdriver managers take care of the installation process for you,
but usually require a second console to be open during test runs,
require an additional command-line flag to be passed in,
and might not have support for less-popular browsers, such as Safari.
You have to run a single update command when a browser has a major release.
-
Mac users, consider using
webdriver-manager,
which supports Chrome and Firefox:
-
In a new console, run npm install -g webdriver-manager
(if that gives you permissions errors, put sudo before npm).
-
Run webdriver-manager update to download the
latest versions of everything.
-
Run webdriver-manager start.
This must always be running when executing tests.
-
Windows users, consider using selenium-standalone,
which supports Chrome, Firefox, IE, and Edge:
-
In a new console, run npm install -g selenium-standalone
(if that gives you permissions errors, put sudo before npm).
-
Run selenium-standalone install to download the
latest versions of everything.
-
Run selenium-standalone start.
This must always be running when executing tests.
Whenever running Smashtest, always run it as
smashtest --test-server=http://localhost:4444/wd/hub
(or whatever the port is), or include that flag in the
config file.
If you upgrade your browser, especially Chrome, make sure you run the update/install command (step 2)
to make sure your drivers are in sync with the browser versions you have installed.
Option 2: Manual install
This option allows you to run everything from just one console, handles any browser,
and doesn't require you to pass in additional command-line flags,
but the install takes longer, and you have to do a manual update when a browser has a major release.
-
You'll need to download individual executables (called "drivers") for each browser you want to automate:
Chrome •
Firefox •
Edge •
IE
Note: Safari 10+ on MacOS comes pre-installed with SafariDriver
-
Each driver executable should be placed in your system's
PATH
-
On MacOS that's usually /usr/local/bin
(run echo $PATH to find out)
-
On Windows that's usually C:\Program Files
(run echo %PATH% to find out)
-
Download the latest version of selenium standalone.
For example, click the 3.9 folder, then download selenium-server-standalone-3.9.1.jar.
-
Set the SELENIUM_SERVER_JAR environment variable to the absolute path of the jar file you just downloaded.
-
On MacOS add the line
export SELENIUM_SERVER_JAR=[path here]
to the file ~/.bash_profile, then restart your console
-
On Windows run
setx -m SELENIUM_SERVER_JAR "[path here]" (you may have to start a second command prompt as administrator),
then restart your original command prompt
If you upgrade your browser, especially Chrome, make sure you re-download and install the correct driver versions.
Option 3: Cloud service or Grid
Alternatively, you can run Smashtest with a Selenium Grid.
This is an advanced, distributed configuration.
-
To use a grid from a cloud service (Sauce Labs, BrowserStack, etc.):
-
Set up the
capabilities in your test.
See your cloud service documentation for details.
-
Set --test-server to your cloud service's url,
or include that flag in the
config file.
-
To install a grid locally:
- Follow steps 1-4 under Option 2 (but do not set the SELENIUM_SERVER_JAR variable)
- In a console, run java -jar selenium-server-standalone-[version].jar -role hub and keep it running
- In another console, run java -jar selenium-server-standalone-[version].jar -role node -hub http://localhost:4444/grid/register and keep it running
-
Whenever running Smashtest, always run it as
smashtest --test-server=http://localhost:4444/wd/hub
(or whatever the port is), or include that flag in the