Videos
Check out our tutorial video series.
Simplify Acceptance Testing by Spawning Selenium Server Before Tests with a Bash Script: A Developer's Guide | Selenium | QA | Automation.
If you write software or QA tests you may have encountered Selenium. It's a popular browser automation tool used for end-to-end acceptance testing. This means you can test applications in a real browser like Firefox or Chrome using code. There are many frameworks that support Selenium (such as Codeception, Specflow, ThirtyFour, and JUnit) but many of them lack a clear way to start Selenium before tests begin. Many developers start Selenium processes manually - but there is an easier way!
You can start a process and send it to the background in linux by appending an ampersand to the command:
You can save the PID of the process you created with the special variable .
One issue many encounter with this technique is that Selenium can take some time to start. This means that any tests executed after the Selenium server is started may run before the server is ready. To make sure the server is ready we can use this nifty one-liner:
This will retry the server endpoint every 5 seconds until a 200 response status is returned or 300 seconds elapses.
We can use this technique to start Selenium before tests, run tests, then kill the process with a simple bash script:
In the example above we ran to run some Elixir ExUnit tests but you could run whatever you like. Hope that helps! For more information on testing with Selenium or using test email accounts see our developers page.
Check out our tutorial video series.
Email and SMS guides for automation and testing.
View github project code for multiple languages.
Latest posts from the MailSlurp team.
Test, build, and automate messaging with a free MailSlurp account.