Skip to content

Commit

Permalink
Update selenium and add retry example
Browse files Browse the repository at this point in the history
  • Loading branch information
andrcuns committed Dec 4, 2023
1 parent 9842117 commit 4ef91f0
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
ruby-version: '3.1'
bundler-cache: true
- name: Test
run: bundle exec cucumber
run: bundle exec cucumber --retry 1
env:
ALLURE_TESTPLAN_PATH: features/support/fixture
- name: Upload allure-results
Expand Down
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ gem 'capybara', '~> 3.39'
gem 'cucumber', '~> 9.1'
gem 'pry', '~> 0.14.2'
gem 'rspec', '~> 3.12'
gem 'selenium-webdriver', '~> 4.10'
gem 'selenium-webdriver', '~> 4.15'
gem 'solargraph', '~> 0.49.0'
gem 'webdrivers', '~> 5.3'
11 changes: 3 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ GEM
parser (>= 3.2.1.0)
ruby-progressbar (1.13.0)
rubyzip (2.3.2)
selenium-webdriver (4.10.0)
selenium-webdriver (4.15.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
Expand Down Expand Up @@ -152,11 +152,7 @@ GEM
unicode-display_width (2.4.2)
uuid (2.3.9)
macaddr (~> 1.0)
webdrivers (5.3.1)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0, < 4.11)
websocket (1.2.9)
websocket (1.2.10)
xpath (3.2.0)
nokogiri (~> 1.8)
yard (0.9.32)
Expand All @@ -173,9 +169,8 @@ DEPENDENCIES
cucumber (~> 9.1)
pry (~> 0.14.2)
rspec (~> 3.12)
selenium-webdriver (~> 4.10)
selenium-webdriver (~> 4.15)
solargraph (~> 0.49.0)
webdrivers (~> 5.3)

BUNDLED WITH
2.3.23
5 changes: 5 additions & 0 deletions features/google.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ Feature: Using Google
gitlab.com
"""
Then I should see gitlab icon

Scenario: Passes on the second try
Given I am a flaky test
When I run this test
Then it passes on the second try
12 changes: 12 additions & 0 deletions features/step_definitions/common_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@
visit("http://#{url}")
end

Given 'I am a flaky test' do
# no-op step to test retry
end

When 'I enter {string}' do |term|
fill_in('q', with: term)
end

When 'I run this test' do
Global.increment_run
end

Then 'I should see results' do
expect(page).to have_css('[role=listbox]')
end
Expand All @@ -19,3 +27,7 @@
Then 'I should see gitlab icon' do
expect(page).to have_css('[id=tanukiHomeDesktop]', visible: :all)
end

Then 'it passes on the second try' do
expect(Global.run).to eq(2)
end
3 changes: 2 additions & 1 deletion features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
require 'pry'
require 'allure-cucumber'
require 'capybara/cucumber'
require 'webdrivers/chromedriver'

require_relative 'global'

# Allure
AllureCucumber.configure do |c|
Expand Down
10 changes: 10 additions & 0 deletions features/support/global.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Global
def self.run
@run ||= 0
end

def self.increment_run
run
@run += 1
end
end

0 comments on commit 4ef91f0

Please sign in to comment.