Use regexps instead of string matching for fields
[sitecorepy.git] / sitecore / __init__.py
index 5a2453043dc8dbade6396bb5cb4faf569102bb7c..91c8e7781e74b95113867ede1ef94b4a3af3fbb6 100755 (executable)
@@ -150,8 +150,8 @@ class SiteCoreConnection (object):
         a = self.w.switch_to_active_element()
         a.send_keys(message+'\n')
 
-    def find_field(self, field):
-        self.logger.info('finding %s field' % field)
+    def find_field(self, field_regexp, name=None):
+        self.logger.info('finding %s field' % field_regexp)
         # found id start by manually focusing in the element and running
         #   >>> a = s.w.switch_to_active_element()
         #   >>> a.get_attribute('id')
@@ -163,9 +163,9 @@ class SiteCoreConnection (object):
         match = False
         for f in fields:
             granddad = f.find_element_by_xpath('/../..')
-            if granddad.get_text().startswith(field):
+            if field_regexp.match(granddad.get_text()) != None:
                 match = True
                 break
         if match != True:
-            raise KeyError(field)
+            raise KeyError(name)
         return (granddad, f)