Skip to content

Commit

Permalink
Took a crack at cobrateam#608
Browse files Browse the repository at this point in the history
I'm on a windows machine so I cannot set up a dev environment to test this myself, if @Qqwy or someone else can test this implementation for me I would appreciate it.
  • Loading branch information
Murkantilism authored Oct 13, 2018
1 parent d8ff6a9 commit 04c36af
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion splinter/driver/lxmldriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,29 @@ def is_text_not_present(self, text, wait_time=None):
if not self._is_text_present(text):
return True
return False


def contains_text(self, text, wait_time=None):
wait_time = wait_time or self.wait_time
end_time = time.time() + wait_time
while time.time() < end_time:
if self._contains_text(text):
return True
return False

def _contains_text(self, text):
try:
body = self.find_by_tag("body").first
# Check if there's a substring match at all
if body.find(text) is not -1:
return True
else:
return False
except ElementDoesNotExist:
# This exception will be thrown if the body tag isn't present
# This has occasionally been observed. Assume that the
# page isn't fully loaded yet
return False

def _element_is_link(self, element):
return element.tag == "a"

Expand Down

0 comments on commit 04c36af

Please sign in to comment.