Skip to content

Commit

Permalink
SELENIUM_EX: add check for num of entries text
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Trifonov committed Aug 31, 2016
1 parent ba66b89 commit ab263a5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions seismograph/ext/selenium/case.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

import os
import re
import logging
from functools import wraps
from pprint import PrettyPrinter
Expand Down Expand Up @@ -103,8 +104,7 @@ def check_exist():
timeout=timeout or proxy.config.POLLING_TIMEOUT,
)

@staticmethod
def text_exist(proxy, text, msg=None, timeout=None):
def text_exist(self, proxy, text, entries=None, msg=None, timeout=None):
def check_text():
try:
return text in proxy.text
Expand All @@ -121,6 +121,13 @@ def check_text():
timeout=timeout or proxy.config.POLLING_TIMEOUT,
)

if entries:
lst = re.findall(text, proxy.text, re.UNICODE)
error_msg = u'Num of entries "{}" == {} expected {}'.format(
text, len(lst), entries,
)
self.len_equal(lst, entries, msg=error_msg)

def texts_exist(self, proxy, texts, timeout=None, msg=None):
for text in texts:
self.text_exist(proxy, text, timeout=timeout, msg=msg)
Expand Down

0 comments on commit ab263a5

Please sign in to comment.