Esempio n. 1
0
 def __init__(self, ctx):
     ContextAware.__init__(self, ctx)
     strategies = {
         'identifier': self._find_by_identifier,
         'id': self._find_by_id,
         'name': self._find_by_name,
         'xpath': self._find_by_xpath,
         'dom': self._find_by_dom,
         'link': self._find_by_link_text,
         'partial link': self._find_by_partial_link_text,
         'css': self._find_by_css_selector,
         'class': self._find_by_class_name,
         'jquery': self._find_by_jquery_selector,
         'sizzle': self._find_by_jquery_selector,
         'tag': self._find_by_tag_name,
         'scLocator': self._find_by_sc_locator,
         'default': self._find_by_default
     }
     self._strategies = NormalizedDict(initial=strategies,
                                       caseless=True,
                                       spaceless=True)
     self._default_strategies = list(strategies)
     self._key_attrs = {
         None: ['@id', '@name'],
         'a': [
             '@id', '@name', '@href',
             'normalize-space(descendant-or-self::text())'
         ],
         'img': ['@id', '@name', '@src', '@alt'],
         'input': ['@id', '@name', '@value', '@src'],
         'button': [
             '@id', '@name', '@value',
             'normalize-space(descendant-or-self::text())'
         ]
     }
Esempio n. 2
0
    def __init__(self, ctx):
        ContextAware.__init__(self, ctx)
        self._locator_suffixes = {
            ('css', 'default'): [''],
            ('css', 'content'): [''],
            ('css', 'header'): [' th'],
            ('css', 'footer'): [' tfoot td'],
            ('css', 'row'): [' tr:nth-child(%s)'],
            ('css', 'last-row'): [' tr:nth-last-child(%s)'],
            ('css', 'col'): [' tr td:nth-child(%s)', ' tr th:nth-child(%s)'],
            ('css', 'last-col'): [' tr td:nth-last-child(%s)', ' tr th:nth-last-child(%s)'],

            ('jquery', 'default'): [''],
            ('jquery', 'content'): [''],
            ('jquery', 'header'): [' th'],
            ('jquery', 'footer'): [' tfoot td'],
            ('jquery', 'row'): [' tr:nth-child(%s)'],
            ('jquery', 'col'): [' tr td:nth-child(%s)', ' tr th:nth-child(%s)'],

            ('sizzle', 'default'): [''],
            ('sizzle', 'content'): [''],
            ('sizzle', 'header'): [' th'],
            ('sizzle', 'footer'): [' tfoot td'],
            ('sizzle', 'row'): [' tr:nth-child(%s)'],
            ('sizzle', 'col'): [' tr td:nth-child(%s)', ' tr th:nth-child(%s)'],

            ('xpath', 'default'): [''],
            ('xpath', 'content'): ['//*'],
            ('xpath', 'header'): ['//th'],
            ('xpath', 'footer'): ['//tfoot//td'],
            ('xpath', 'row'): ['//tr[%s]//*'],
            ('xpath', 'last-row'): [' //tbody/tr[position()=last()-(%s-1)]'],
            ('xpath', 'col'): ['//tr//*[self::td or self::th][%s]'],
            ('xpath', 'last-col'): [' //tbody/tr/td[position()=last()-(%s-1)]', ' //tbody/tr/td[position()=last()-(%s-1)]']
        }
 def __init__(self, ctx):
     ContextAware.__init__(self, ctx)
     strategies = {
         'identifier': self._find_by_identifier,
         'id': self._find_by_id,
         'name': self._find_by_name,
         'xpath': self._find_by_xpath,
         'dom': self._find_by_dom,
         'link': self._find_by_link_text,
         'partial link': self._find_by_partial_link_text,
         'css': self._find_by_css_selector,
         'class': self._find_by_class_name,
         'jquery': self._find_by_jquery_selector,
         'sizzle': self._find_by_jquery_selector,
         'tag': self._find_by_tag_name,
         'scLocator': self._find_by_sc_locator,
         'default': self._find_by_default
     }
     self._strategies = NormalizedDict(initial=strategies, caseless=True,
                                       spaceless=True)
     self._default_strategies = list(strategies)
     self._key_attrs = {
         None: ['@id', '@name'],
         'a': ['@id', '@name', '@href',
               'normalize-space(descendant-or-self::text())'],
         'img': ['@id', '@name', '@src', '@alt'],
         'input': ['@id', '@name', '@value', '@src'],
         'button': ['@id', '@name', '@value',
                    'normalize-space(descendant-or-self::text())']
     }
Esempio n. 4
0
 def __init__(self, ctx):
     ContextAware.__init__(self, ctx)
     self._strategies = {
         'title': self._select_by_title,
         'name': self._select_by_name,
         'url': self._select_by_url,
         'default': self._select_by_default
     }
Esempio n. 5
0
 def __init__(self, ctx):
     ContextAware.__init__(self, ctx)
     self._strategies = {
         "title": self._select_by_title,
         "name": self._select_by_name,
         "url": self._select_by_url,
         "default": self._select_by_default,
     }
 def __init__(self, ctx):
     ContextAware.__init__(self, ctx)
     self._strategies = {
         'title': self._select_by_title,
         'name': self._select_by_name,
         'url': self._select_by_url,
         'default': self._select_by_default
     }
Esempio n. 7
0
 def __init__(self, ctx):
     ContextAware.__init__(self, ctx)
     strategies = {
         "identifier": self._find_by_identifier,
         "id": self._find_by_id,
         "name": self._find_by_name,
         "xpath": self._find_by_xpath,
         "dom": self._find_by_dom,
         "link": self._find_by_link_text,
         "partial link": self._find_by_partial_link_text,
         "css": self._find_by_css_selector,
         "class": self._find_by_class_name,
         "jquery": self._find_by_jquery_selector,
         "sizzle": self._find_by_jquery_selector,
         "tag": self._find_by_tag_name,
         "scLocator": self._find_by_sc_locator,
         "relative": self._find_by_relative_selector,
         "default": self._find_by_default,
     }
     self._strategies = NormalizedDict(initial=strategies,
                                       caseless=True,
                                       spaceless=True)
     self._default_strategies = list(strategies)
     self._key_attrs = {
         None: ["@id", "@name"],
         "a": [
             "@id",
             "@name",
             "@href",
             "normalize-space(descendant-or-self::text())",
         ],
         "img": ["@id", "@name", "@src", "@alt"],
         "input": ["@id", "@name", "@value", "@src"],
         "button": [
             "@id",
             "@name",
             "@value",
             "normalize-space(descendant-or-self::text())",
         ],
     }
     self._split_re = re.compile(
         r" >> (?=identifier ?[:|=]|id ?[:|=]|name ?[:|=]|xpath ?[:|=]|dom ?[:|=]|link ?[:|=]|partial link ?[:|=]"
         r"|css ?[:|=]|class ?[:|=]|jquery ?[:|=]|sizzle ?[:|=]|tag ?[:|=]|scLocator ?[:|=])",
         re.IGNORECASE,
     )
     self._relative_locator_kw = (
         "near",
         "above",
         "below",
         "to_right_of",
         "to_left_of",
     )
     self._relative_locator_split_re = re.compile(
         f":\s*?({'|'.join(self._relative_locator_kw)})\s*?\((.*?)\)")
 def __init__(self, ctx):
     ContextAware.__init__(self, ctx)
     self._locators = {
         'content': ['//*'],
         'header': ['//th'],
         'footer': ['//tfoot//td'],
         'row': ['//tr[{row}]//*'],
         'last-row': ['//tbody/tr[position()=last()-({row}-1)]'],
         'col': ['//tr//*[self::td or self::th][{col}]'],
         'last-col': ['//tbody/tr/td[position()=last()-({col}-1)]',
                      '//tbody/tr/td[position()=last()-({col}-1)]']
     }
Esempio n. 9
0
 def __init__(self, ctx):
     ContextAware.__init__(self, ctx)
     self._locators = {
         'content': ['//*'],
         'header': ['//th'],
         'footer': ['//tfoot//td'],
         'row': ['//tr[{row}]//*'],
         'last-row': ['//tbody/tr[position()=last()-({row}-1)]'],
         'col': ['//tr//*[self::td or self::th][{col}]'],
         'last-col': [
             '//tbody/tr/td[position()=last()-({col}-1)]',
             '//tbody/tr/td[position()=last()-({col}-1)]'
         ]
     }
Esempio n. 10
0
 def __init__(self, ctx):
     ContextAware.__init__(self, ctx)
     strategies = {
         "identifier": self._find_by_identifier,
         "id": self._find_by_id,
         "name": self._find_by_name,
         "xpath": self._find_by_xpath,
         "dom": self._find_by_dom,
         "link": self._find_by_link_text,
         "partial link": self._find_by_partial_link_text,
         "css": self._find_by_css_selector,
         "class": self._find_by_class_name,
         "jquery": self._find_by_jquery_selector,
         "sizzle": self._find_by_jquery_selector,
         "tag": self._find_by_tag_name,
         "scLocator": self._find_by_sc_locator,
         "default": self._find_by_default,
     }
     self._strategies = NormalizedDict(initial=strategies,
                                       caseless=True,
                                       spaceless=True)
     self._default_strategies = list(strategies)
     self._key_attrs = {
         None: ["@id", "@name"],
         "a": [
             "@id",
             "@name",
             "@href",
             "normalize-space(descendant-or-self::text())",
         ],
         "img": ["@id", "@name", "@src", "@alt"],
         "input": ["@id", "@name", "@value", "@src"],
         "button": [
             "@id",
             "@name",
             "@value",
             "normalize-space(descendant-or-self::text())",
         ],
     }
 def __init__(self, ctx, name, finder):
     ContextAware.__init__(self, ctx)
     self.name = name
     self.finder = finder