TL;DR
In this post, we will run our simple shop scenario using Browserstack infrastructure.
Sign up at Browserstack. By default, you get a free plan with 100 automation minutes per month. Minutes are counted for script execution time. Go to the settings page where you will found our browserstack user and key values. Browserstack has many features. For automation, the most essential element is that you can select various browsers and os combination, along with their versions.
Let’s observe chapter 07 pull request.
.env_template
This is a new file. It is a template for environment variables that hold Browserstack user and key values:
cp .env_template .env
Enter Browserstack user and key secrets
source .env
.gitignore
We added the .env file as I do not want to be my Browserstack secrets publicly available. Even if you use private git repo, this is a good security practice.
README.md
Added chapter how to set up Browserstack secrets.
config/application.yml
Added variables for Browserstack Browser and OS type and versions.
features/support/env.rb
As you probably assumed, all config is taking place in env.rb file. This is Cucumber gem author decision. We load env variables using the ENV ruby method. This should be done before Before and After scenario methods. Using capabilities class, we set up Browserstack (or any remote selenium provider). Magic happens on line 48, where we create remote Browser class using :remote and Browserstack URL options.
Line 62 is Browserstack specific. If the scenario fails, you will know that from your console, but Browserstack does not have a clue what is happening inside the browser. So browser stack enables you to let it know when the scenario failed using rest API client. Here is the scenario result report on Browserstack. You have an execution video and Selenium action log: