One of the tools to automate the interaction with the browser is Selenium Webdriver. In fact, automated web page tests using Selenium Webdriver look rather cumbersome. Here is a “small” example that opens the Google search page in parallel in two browsers, fills in the search string and sends the form:

As practice has shown, with small changes in the structure of the page, it is often necessary to rework a fairly large amount of code, which again entails a large investment of time. Attempts were made to search for tools to make the tests less voluminous and more readable, but they simply did not appear. It was decided to develop gems with DSL (English Domain Specific Language, DSL - "subject-specific language"), which would allow to create intuitive tests that do not contain anything superfluous and they could be easily and quickly edited. Hem was named SelWeT (Selenium Web Test).
The development used the Ruby 2.1.3 language and the selenium-webdriver gems, test-unit and shoulda-context. To select elements on the page, it was decided to use only CSS selectors, since they cover all the necessary needs (the choice of a group or one specific element on a page). To some extent this simplified the task.
')
SelWeT hem allows you to:
- conduct testing in one or several browsers (runs in parallel);
- check the presence of one or a group of elements on the page;
- interact with page elements (click on an element, move the cursor on an element, fill in a text field, fill out and submit a form, select values in select, check the checkbox and radio status, switch to iframe, etc.);
- interact with the browser (click on a link, clear the cache, take a screenshot of an open page, open a link in a new window, etc.).
To perform tests, you need to have version 2.44 or later running on a local or remote Selenium Server machine with an indication of the necessary drivers (drivers are required for IE, Chrome).
An example of running Selenium Server with a Chrome driver on a Windows 7 machine:
java -jar selenium-server-standalone-2.44.0.jar -Dwebdriver.chrome.driver = /path/to/chromedriver.exe
Of course, you must first install the necessary browser on this machine.
Gemfile for the machine where the tests will be run:
gem 'selenium-webdriver', '~> 2.44.0' gem 'test-unit', '~> 3.0.8' gem 'shoulda-context', '~> 1.2.1' gem 'selwet', '~> 0.0.2'
An example demonstrating the functionality of a heme:
require 'selwet'
As you can see from the example, SelWeT allows you to quickly outline a clear functional test.
To install the gem you need to run
gem install selwet
The documentation is in the repository on github.
SelWeT:
https://github.com/inventos/selwet.gitSelenium wiki:
https://code.google.com/p/selenium/wiki/Grid2Shoulda-context:
https://github.com/thoughtbot/shoulda-contextTest-unit:
https://github.com/test-unit/test-unit