Restrict when text match will be attempted in expression
This commit is contained in:
parent
5409abf225
commit
4ecbcd9f7b
|
@ -154,14 +154,16 @@ module Capybara
|
||||||
@selector.format
|
@selector.format
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def matching_text
|
||||||
|
options[:text] || options[:exact_text]
|
||||||
|
end
|
||||||
|
|
||||||
def text_fragments
|
def text_fragments
|
||||||
text = (options[:text] || options[:exact_text])
|
(text = matching_text).is_a?(String) ? text.split : []
|
||||||
text.is_a?(String) ? text.split : []
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def xpath_text_conditions
|
def xpath_text_conditions
|
||||||
text = (options[:text] || options[:exact_text])
|
case (text = matching_text)
|
||||||
case text
|
|
||||||
when String
|
when String
|
||||||
text.split.map { |txt| XPath.contains(txt) }.reduce(&:&)
|
text.split.map { |txt| XPath.contains(txt) }.reduce(&:&)
|
||||||
when Regexp
|
when Regexp
|
||||||
|
@ -175,9 +177,9 @@ module Capybara
|
||||||
|
|
||||||
def try_text_match_in_expression?
|
def try_text_match_in_expression?
|
||||||
first_try? &&
|
first_try? &&
|
||||||
(options[:text] || options[:exact_text]) &&
|
matching_text &&
|
||||||
@resolved_node&.respond_to?(:session) &&
|
@resolved_node.is_a?(Capybara::Node::Base) &&
|
||||||
@resolved_node.session.driver.wait?
|
@resolved_node.session&.driver&.wait?
|
||||||
end
|
end
|
||||||
|
|
||||||
def first_try?
|
def first_try?
|
||||||
|
|
Loading…
Reference in New Issue