summaryrefslogtreecommitdiff
path: root/qa/qa/page/base.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-09 09:10:17 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-09 09:10:17 +0000
commitad0265eead72a624ce7a020847db4f0f0c877e57 (patch)
tree206e0564b02aa9530e3c95f70eb10a77e074bdf0 /qa/qa/page/base.rb
parent4dfc8711171fe0c04bc6b8b224687603026dea46 (diff)
downloadgitlab-ce-ad0265eead72a624ce7a020847db4f0f0c877e57.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa/qa/page/base.rb')
-rw-r--r--qa/qa/page/base.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb
index 4ccf9e2f168..42208f05c89 100644
--- a/qa/qa/page/base.rb
+++ b/qa/qa/page/base.rb
@@ -14,6 +14,20 @@ module QA
ElementNotFound = Class.new(RuntimeError)
+ class NoRequiredElementsError < RuntimeError
+ def initialize(page_class)
+ @page_class = page_class
+ super
+ end
+
+ def to_s
+ <<~MSG.strip % { page: @page_class }
+ %{page} has no required elements.
+ See https://docs.gitlab.com/ee/development/testing_guide/end_to_end/dynamic_element_validation.html#required-elements
+ MSG
+ end
+ end
+
def_delegators :evaluator, :view, :views
def initialize
@@ -250,6 +264,8 @@ module QA
end
def element_selector_css(name, *attributes)
+ return name.selector_css if name.is_a? Page::Element
+
Page::Element.new(name, *attributes).selector_css
end
@@ -296,10 +312,24 @@ module QA
views.flat_map(&:elements)
end
+ def self.required_elements
+ elements.select(&:required?)
+ end
+
def send_keys_to_element(name, keys)
find_element(name).send_keys(keys)
end
+ def visible?
+ raise NoRequiredElementsError.new(self.class) if self.class.required_elements.empty?
+
+ self.class.required_elements.each do |required_element|
+ return false if has_no_element? required_element
+ end
+
+ true
+ end
+
class DSL
attr_reader :views