mrkcor / echo

Echo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Echo

This is an example project to demonstrate testing a Rack application (in this case using Sinatra) using Capybara and Selenium with various options, I wrote an accompanying blog article here: https://without-brains.net/2020/10/25/capybara-with-selenium-and-vagrant-without-rails/

This project runs on ruby 2.7.x (but will likely function with 2.6.x too).

If you have any issues, suggestions, improvements, etc. then please log them using GitHub issues.

Usage

This project comes with a very basic Vagrant box.

To run the Rack application run "bundle exec rackup", if you then visit the root you will see a webpage with a text input and button. Entering a text and clicking the button will refresh the page echoing back the message that you entered.

To run the tests run "bundle exec rake test", by default this will run against a headless Firefox (this will require you to have the geckodriver installed).

The following environemnt variables influence how the tests are run:

  • CAPYBARA_DRIVER[=selenium_headless] is the Capybara driver to use, besides the defaults you can also use selenium_remote here to run against a Selenium instance running elsewhere
  • CAPYBARA_SAVE_PATH[=tmp/] is where Capybara saves its pages, screenshots, etc.
  • CAPYBARA_SERVER_HOST is the IP address to which Capybara binds the Rack server that it starts to run the tests against
  • CAPYBARA_SERVER_PORT is the portnumber to which Capybara binds the Rack server that it starts to run the tests against
  • SELENIUM_REMOTE_BROWSER[=firefox] is the browser to use when selecting the selenium_remote driver
  • SELENIUM_REMOTE_HOST[=127.0.0.1] is the hostname or IP address where the Selenium instance is running for the selenium_remote driver
  • SELENIUM_REMOTE_PORT[=4444] is the port on the SELENIUM_REMOTE_HOST where the Selenium instance is running for the selenium_remote driver
  • SELENIUM_SCREEN_SIZE[=desktop] is the screen size that the Selenium browser must use, select a named shortcut or enter a direct resolution in the format WIDTHxHEIGHT. Named options are galaxy_s9, iphone_6, iphone_6_plus, iphone_7, iphone_7_plus, iphone_8, iphone_8_plus, iphone_x, ipad and desktop
  • SELENIUM_SCREEN_TURNED can be set to 1 to emulate turning the screen for named resolution

License

Echo is released under the MIT license.

Author

Mark Cornelissen

About

Echo


Languages

Language:Ruby 94.4%Language:HTML 5.6%