Skip to content

Commit

Permalink
Rename FindByDataStarAttribute to FindByAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
jsfehler committed Nov 16, 2019
1 parent b0c21bb commit 494b763
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions stere/strategy/splinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,18 @@ class FindByValue(SplinterBase):
strategy = 'value'


class FindByDataStarAttribute(SplinterBase):
"""Strategy to find an element by an arbitrary data-* attribute."""
class FindByAttribute(SplinterBase):
"""Strategy to find an element by an arbitrary attribute."""

def _find_all(self):
"""Find from page root."""
return self.browser.find_by_xpath(
f'.//*[@{self._data_star_attribute}="{self.locator}"]')
f'//*[@{self._attribute}="{self.locator}"]')

def _find_all_in_parent(self):
"""Find from inside parent element."""
return self.parent_locator.find_by_xpath(
f'./*[@{self._data_star_attribute}="{self.locator}"]')
f'.//*[@{self._attribute}="{self.locator}"]')


def add_data_star_strategy(data_star_attribute):
Expand All @@ -145,6 +145,6 @@ def add_data_star_strategy(data_star_attribute):
data_star_attribute (str): The data-* attribute to use in the new
strategy.
"""
find_by_data_star = copy.deepcopy(FindByDataStarAttribute)
find_by_data_star._data_star_attribute = data_star_attribute
find_by_data_star = copy.deepcopy(FindByAttribute)
find_by_data_star._attribute = data_star_attribute
return strategy(data_star_attribute)(find_by_data_star)
4 changes: 2 additions & 2 deletions tests/splinter/test_splinter_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from stere.fields import Field
from stere.strategy.splinter import (
FindByAttribute,
FindByCss,
FindByDataStarAttribute,
FindById,
FindByName,
FindByTag,
Expand Down Expand Up @@ -43,7 +43,7 @@ def test_unexpected_strategy():
assert strategies == {
'css': FindByCss,
# data-test-id is present because of unit tests
'data-test-id': FindByDataStarAttribute,
'data-test-id': FindByAttribute,
'xpath': FindByXPath,
'tag': FindByTag,
'name': FindByName,
Expand Down

0 comments on commit 494b763

Please sign in to comment.