diff --git a/se_wrapper/__init__.py b/se_wrapper/__init__.py index a03c2c3..10fdf89 100644 --- a/se_wrapper/__init__.py +++ b/se_wrapper/__init__.py @@ -1,2 +1,2 @@ name = "selen-kaa" -__all__ = ["browser_driver.py", "wrapped_webelement.py", "errors"] +__all__ = ["browser_driver", "waits", "element"] diff --git a/se_wrapper/browser_driver.py b/se_wrapper/browser_driver.py index db94fda..3f39496 100644 --- a/se_wrapper/browser_driver.py +++ b/se_wrapper/browser_driver.py @@ -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 @@ -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 @@ -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. diff --git a/se_wrapper/element/wrapped_element_interface.py b/se_wrapper/element/se_element_interface.py similarity index 91% rename from se_wrapper/element/wrapped_element_interface.py rename to se_wrapper/element/se_element_interface.py index ac7128e..7d4beee 100644 --- a/se_wrapper/element/wrapped_element_interface.py +++ b/se_wrapper/element/se_element_interface.py @@ -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. """ diff --git a/se_wrapper/element/wrapped_elements_array.py b/se_wrapper/element/se_elements_array.py similarity index 79% rename from se_wrapper/element/wrapped_elements_array.py rename to se_wrapper/element/se_elements_array.py index 4211ae6..3a5cd37 100644 --- a/se_wrapper/element/wrapped_elements_array.py +++ b/se_wrapper/element/se_elements_array.py @@ -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(). @@ -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] diff --git a/se_wrapper/element/wrapped_webelement.py b/se_wrapper/element/se_web_element.py similarity index 96% rename from se_wrapper/element/wrapped_webelement.py rename to se_wrapper/element/se_web_element.py index acbee01..68f673b 100644 --- a/se_wrapper/element/wrapped_webelement.py +++ b/se_wrapper/element/se_web_element.py @@ -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 @@ -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. diff --git a/se_wrapper/help_utils.py b/se_wrapper/help_utils.py index 6bcb815..03c71b1 100644 --- a/se_wrapper/help_utils.py +++ b/se_wrapper/help_utils.py @@ -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 diff --git a/se_wrapper/waits.py b/se_wrapper/waits.py index 1c9b443..346e5c8 100644 --- a/se_wrapper/waits.py +++ b/se_wrapper/waits.py @@ -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 @@ -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 = {