Skip to content

Commit

Permalink
Renamed wrapped element.
Browse files Browse the repository at this point in the history
  • Loading branch information
VicGrygorchyk committed Nov 6, 2019
1 parent ac38e69 commit 1bf7966
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion se_wrapper/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name = "selen-kaa"
__all__ = ["browser_driver.py", "wrapped_webelement.py", "errors"]
__all__ = ["browser_driver", "waits", "element"]
12 changes: 6 additions & 6 deletions se_wrapper/browser_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from selenium.webdriver import ActionChains
from selenium.webdriver.remote.webelement import WebElement

from se_wrapper.element.wrapped_elements_array import WrappedElementsArray
from se_wrapper.element.wrapped_webelement import WrappedWebElement
from se_wrapper.element.se_elements_array import SeElementsArray
from se_wrapper.element.se_web_element import SeWebElement
from se_wrapper.waits import Wait
from se_wrapper import help_utils

Expand Down Expand Up @@ -51,7 +51,7 @@ def hooked(*args, **kwargs):
def action_chains(self):
return ActionChains(self._webdriver)

def init_web_element(self, selector: str, timeout: TimeoutType = DEFAULT_TIMEOUT) -> WrappedWebElement:
def init_web_element(self, selector: str, timeout: TimeoutType = DEFAULT_TIMEOUT) -> SeWebElement:
"""Init a new WrappedWebElement.
Lazy initialization. Element would be called on the time of first interaction.
:param selector: str as css selector or xpath
Expand All @@ -60,14 +60,14 @@ def init_web_element(self, selector: str, timeout: TimeoutType = DEFAULT_TIMEOUT
"""
if selector is None:
raise Exception("Selector should be not empty.")
return WrappedWebElement(self, selector, timeout)
return SeWebElement(self, selector, timeout)

def init_all_web_elements(self, selector: str, timeout: TimeoutType = DEFAULT_TIMEOUT) -> WrappedElementsArray:
def init_all_web_elements(self, selector: str, timeout: TimeoutType = DEFAULT_TIMEOUT) -> SeElementsArray:
"""Init a list with references to WrappedWebElement.
Lazy initialization. All elements would be called on the time of first interaction
with any of the elements.
"""
return WrappedElementsArray(self, selector, timeout)
return SeElementsArray(self, selector, timeout)

def find_element_by_css(self, selector: str, timeout: TimeoutType = DEFAULT_TIMEOUT) -> WebElement:
""" Universal method to look for the web element by provided selector.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from abc import ABC


class WrappedElementInterface(ABC):
class SeElementInterface(ABC):
"""Abstract class for wrapped web element.
Used for type reference. Shall be implemented in separate class.
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from se_wrapper.element.wrapped_webelement import WrappedWebElement
from se_wrapper.element.se_web_element import SeWebElement


class WrappedElementsArray:
class SeElementsArray:
"""Lazy initialization of a list of web_elements.
We need this for calling a list of wrapped web_elements,
instead of standard find_elements().
Expand All @@ -20,6 +20,6 @@ def lazy_array(self):
return self._elements_array

def __getitem__(self, index):
element = WrappedWebElement(self._webdriver, self._css_selector, self._timeout)
element = SeWebElement(self._webdriver, self._css_selector, self._timeout)
element.web_element = self._elements_array[index]
return self._elements_array[index]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from se_wrapper import help_utils
from se_wrapper.browser_driver import BrowserDriver
from se_wrapper.element.element_waits import ElementWaits
from se_wrapper.element.wrapped_element_interface import WrappedElementInterface
from se_wrapper.element.se_element_interface import SeElementInterface
from se_wrapper.errors import ElementNotClickableError
from se_wrapper.element.expectations import Expectations

Expand All @@ -15,7 +15,7 @@
TimeoutType = help_utils.TimeoutType


class WrappedWebElement(WrappedElementInterface):
class SeWebElement(SeElementInterface):
"""Class is used to provide a lazy initialization of the WebElement.
WebElement is going to be searched only when is called.
Web element can be declared in __init__ of the page class and be found only when needed for interaction.
Expand Down
4 changes: 2 additions & 2 deletions se_wrapper/help_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webelement import WebElement

from se_wrapper.element.wrapped_element_interface import WrappedElementInterface
from se_wrapper.element.se_element_interface import SeElementInterface


ElementType = Union[str, WebElement, WrappedElementInterface]
ElementType = Union[str, WebElement, SeElementInterface]
TimeoutType = Union[int, float]
DEFAULT_TIMEOUT = 4

Expand Down
4 changes: 2 additions & 2 deletions se_wrapper/waits.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from selenium.common.exceptions import NoSuchElementException, TimeoutException, StaleElementReferenceException

from se_wrapper import help_utils
from se_wrapper.element.wrapped_element_interface import WrappedElementInterface
from se_wrapper.element.se_element_interface import SeElementInterface


TimeoutType = help_utils.TimeoutType
Expand Down Expand Up @@ -267,7 +267,7 @@ def _switch_on_element_type(target, string, web_element_type, wrapped_element_ty
Selenium WebElement or WrappedWebElement.
"""
if isinstance(target, WrappedElementInterface):
if isinstance(target, SeElementInterface):
func = wrapped_element_type
else:
switch = {
Expand Down

0 comments on commit 1bf7966

Please sign in to comment.