diff --git a/README.md b/README.md
index b7e267f..d0eb400 100644
--- a/README.md
+++ b/README.md
@@ -139,6 +139,9 @@ todos_index.has_no_todo_matching?(text: "Buy milk") # => has_no_css?("ul li span
todos_index.todos.has_count_of?(number) # => has_css?("ul li span[data-role=todo-name]", count: number)
todos_index.has_todos_count?(number) # => has_css?("ul li span[data-role=todo-name]", count: number)
+
+todos_index.todos.has_any_elements? # => has_css?("ul li span[data-role=todo-name]")
+todos_index.todos.has_no_elements? # => has_no_css?("ul li span[data-role=todo-name]")
```
The methods defined by PageEz can be passed additional options from Capybara. Refer to documentation for the following methods:
diff --git a/lib/page_ez/has_many_result.rb b/lib/page_ez/has_many_result.rb
index 988cb83..f25f249 100644
--- a/lib/page_ez/has_many_result.rb
+++ b/lib/page_ez/has_many_result.rb
@@ -20,5 +20,16 @@ def has_count_of?(count)
**@options.merge(count: count)
)
end
+
+ def has_any_elements?
+ @container.has_css?(
+ @selector,
+ **@options
+ )
+ end
+
+ def has_no_elements?
+ @container.has_no_css?(@selector, **@options)
+ end
end
end
diff --git a/lib/page_ez/method_generators/define_has_many_result_methods.rb b/lib/page_ez/method_generators/define_has_many_result_methods.rb
index 22409c4..d1cdbf9 100644
--- a/lib/page_ez/method_generators/define_has_many_result_methods.rb
+++ b/lib/page_ez/method_generators/define_has_many_result_methods.rb
@@ -34,6 +34,14 @@ def run(target)
target.logged_define_method("has_#{name}_count?") do |count, *args|
send(name, *args).has_count_of?(count)
end
+
+ target.logged_define_method("has_#{name}?") do |*args|
+ send(name, *args).has_any_elements?
+ end
+
+ target.logged_define_method("has_no_#{name}?") do |*args|
+ send(name, *args).has_no_elements?
+ end
end
end
end
diff --git a/spec/features/capybara_javascript_spec.rb b/spec/features/capybara_javascript_spec.rb
index 35e2664..f38af51 100644
--- a/spec/features/capybara_javascript_spec.rb
+++ b/spec/features/capybara_javascript_spec.rb
@@ -150,4 +150,54 @@
expect(test_page.list.items).to have_count_of(4)
end
end
+
+ it "allows for checking for any results" do
+ page = build_page(<<-HTML)
+
+
+
+
+
+
+