summaryrefslogtreecommitdiff
path: root/qa/qa/page/validatable.rb
blob: 7cc7f1a128e8bfb38e22858c298d7b851b3f1a64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

module QA
  module Page
    module Validatable
      PageValidationError = Class.new(StandardError)

      def validate_elements_present!
        base_page = self.new

        elements.each do |element|
          next unless element.required?

          # TODO: this wait needs to be replaced by the wait class
          unless base_page.has_element?(element.name, wait: 10)
            raise Validatable::PageValidationError, "#{element.name} did not appear on #{self.name} as expected"
          end
        end
      end
    end
  end
end