diff --git a/stere/strategy/splinter.py b/stere/strategy/splinter.py index 66faff66..53ca99fa 100644 --- a/stere/strategy/splinter.py +++ b/stere/strategy/splinter.py @@ -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): @@ -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) diff --git a/tests/splinter/test_splinter_strategies.py b/tests/splinter/test_splinter_strategies.py index 4d5c1504..c8c43b42 100644 --- a/tests/splinter/test_splinter_strategies.py +++ b/tests/splinter/test_splinter_strategies.py @@ -6,8 +6,8 @@ from stere.fields import Field from stere.strategy.splinter import ( + FindByAttribute, FindByCss, - FindByDataStarAttribute, FindById, FindByName, FindByTag, @@ -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,