Skip to content

Latest commit

 

History

History
95 lines (70 loc) · 2.25 KB

README.md

File metadata and controls

95 lines (70 loc) · 2.25 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
    After do |scenario|
        if scenario.failed?
            take_screenshot
        end
    end

    AfterStep do |scenario|
        take_screenshot
    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