Skip to content

Latest commit

 

History

History
100 lines (74 loc) · 2.32 KB

README.md

File metadata and controls

100 lines (74 loc) · 2.32 KB

Docker Ubuntu 18.10 Mate Desktop with Cucumber

Docker container for automatize your cucumber test in browser Chrome and FireFox with screenshots.

Libraries preload.

Generate a test skeleton

- ./test/
  - features/
    - mytest.feature
    - screenshot/
    - step_definitions/
    - support/
      - env.rb
      - cucumber-screenshot.rb

env.rb file

Chrome example:

require 'selenium-webdriver'
require 'selenium-cucumber'

caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"args" => [ "--disable-web-security", "--no-sandbox" ]})

$driver = Selenium::WebDriver.for :remote, desired_capabilities: caps

FireFox example:

require 'selenium-webdriver'
require 'selenium-cucumber'

$driver = Selenium::WebDriver.for :remote, desired_capabilities: :firefox
$driver.manage().window().maximize()

cucumber-screenshot.rb file

begin
  require 'cucumber_screenshot'
  World(CucumberScreenshot::World)

  After do |scenario|
    if scenario.failed?
      screenshot
    end
  end

  AfterStep('@screenshot') do |scenario|
    if screenshot_due?
      screenshot
    end
  end
  rescue Exception => e
    puts "Snapshots not available for this environment.\n"
end

Your features test

By using predefined steps you can automate your test cases more quickly, more efficiently and without much coding.

The predefined steps are located here

Run in docker

docker run --volume ./test:/opt/cucumber sergioortegagomez/docker-ubuntu-cucumber

Run in docker-compose

services:
  test:
    image: sergioortegagomez/docker-ubuntu-cucumber
    volumes:
      - ./test:/opt/cucumber

Examples