Check if the element contains the given text.

 @param  [String, Regexp] expected_text The text to look for.
 @return [Fixnum, nil]  The index of the matched text, or nil if it doesn't match.
484981
def contains_text(expected_text)
      assert_exists
      return nil unless respond_to? :text

      case expected_text
      when Regexp
        text() =~ expected_text
      when String
        text().index(expected_text)
      else
        raise TypeError, "expected String or Regexp, got #{expected_text.inspect}:#{expected_text.class}"
      end
    end
105130
def search(self, text, lookup=None):
        ''''''
        return self.query().search(text, lookup=lookup)
628544
def page_should_contain_text(self, text, loglevel='INFO'):
        
        if not self._is_text_present(text):
            self.log_source(loglevel)
            raise AssertionError("Page should have contained text '%s' "
                                 "but did not" % text)
        self._info("Current page contains text '%s'." % text)
58006
def match?(arr, parser=nil)
      arr = arr.to_a
      return false if arr.length != self.length
      each_with_index do |node, i|
        node.match?(arr[i], parser) or return false
      end
      return true
    end
237275
public Match find(String text) {

		if (regexp == null)
			return null;

		Matcher m = regexp.matcher(text);
		if (m.find()) {
			Match match = new Match();
			match.setText(text);
			match.match = m;
			match.start = m.start(0);
			match.end = m.end(0);
			match.line = text;
			return match;
		}
		else {
			return null;
		}
	}
502938
public boolean verifyText(final By by, final String text) {
		WebElement element = driver.findElement(by);

		if (element.getText().equals(text)) {
			LOG.info("Element: " + element + " contains the given text: "
					+ text);
			return true;
		}

		LOG.info("Element: " + element + " does NOT contain the given text: "
				+ text);

		return false;
	}
322197
def is_paired(text, open='(', close=')'):
    
    count = 0
    escape = False
    for c in text:
        if escape:
            escape = False
        elif c == '\\':
            escape = True
        elif c == open:
            count += 1
        elif c == close:
            if count == 0:
                return False
            count -= 1
    return count == 0
1186413
def _check_element(self, lookup_strings, instance):
        
        for q, val in lookup_strings.items():
            if not field_lookup(instance, q, val, True):
                return False

        return True
1089069
def merge_texts!(hash, element)
        unless element.has_text?
          hash
        else
          # must use value to prevent double-escaping
          merge!(hash, CONTENT_KEY, element.texts.sum(&:value))
        end
      end
1182417
public function elementTextNotContains($selectorType, $selector, $text)
    {
        $element = $this->elementExists($selectorType, $selector);
        $actual = $element->getText();
        $regex = '/'.preg_quote($text, '/').'/ui';

        $message = sprintf(
            'The text "%s" appears in the text of the %s, but it should not.',
            $text,
            $this->getMatchingElementRepresentation($selectorType, $selector)
        );

        $this->assertElementText(!preg_match($regex, $actual), $message, $element);
    }
892344
def match(pattern_element)
    @num_match_attempts += 1
    return :no_pattern_element unless pattern_element
    return :skipped if pattern_element.delimiter &&
      (
      if last_match
        last_match.delimiter       # don't match two delimiters in a row
      else
        @num_match_attempts > 1   # don't match a delimiter as the first element unless this is the first match attempt
      end
      )

    if result = pattern_element.parse(self)
      add_match result, pattern_element.name # success, but don't keep EmptyNodes
    end
  end
752789
def matches_content?
      return true if @expected_content.empty?

      @actual_content = ChefSpec::Renderer.new(@runner, resource).content

      return false if @actual_content.nil?

      # Knock out matches that pass. When we're done, we pass if the list is
      # empty. Otherwise, @expected_content is the list of matchers that
      # failed
      @expected_content.delete_if do |expected|
        if expected.is_a?(Regexp)
          @actual_content =~ expected
        elsif RSpec::Matchers.is_a_matcher?(expected)
          expected.matches?(@actual_content)
        elsif expected.is_a?(Proc)
          expected.call(@actual_content)
          # Weird RSpecish, but that block will return false for a negated check,
          # so we always return true. The block will raise an exception if the
          # assertion fails.
          true
        else
          @actual_content.include?(expected)
        end
      end
      @expected_content.empty?
    end
41896
def tag(self, text):
        
        matches = self._match(text.text)
        matches = self._resolve_conflicts(matches)

        if self.return_layer:
            return matches
        else:
            text[self.layer_name] = matches
81015
function hasSuffix(text, suffix) {
  let exp = new RegExp(`${suffix.pattern}$`);
  let result = exp.test(text);

  if (suffix.antipattern) {
    let exp = new RegExp(`${suffix.antipattern}$`);
    result = result && !exp.test(text);
  }

  return result;
}
706786
protected boolean verifyPatternMatch(String text) {
		if (this.expectedPattern == null) {
			return false;
		}
		return this.expectedPattern.matcher(text).matches();
	}
779713
public boolean textPresent(String expectedText) {
        try {
            String bodyText = driver.findElement(By.tagName("body")).getText();
            return bodyText.contains(expectedText);
        } catch (Exception e) {
            log.info(e);
            return false;
        }
    }
565403
def _find_element_text(element, match, default=None):
    
    child = element.find(match)
    try:
        return child.text
    except AttributeError:
        if default is not None:
            return default
        else:
            raise MissingElementError(element, match)