Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def reset_object(self, driver_wrapper=None):
"""Reset each page element object
:param driver_wrapper: driver wrapper instance
"""
from toolium.pageelements.page_elements import PageElements
if driver_wrapper:
self.driver_wrapper = driver_wrapper
self._web_element = None
for element in self._get_page_elements():
element.reset_object(driver_wrapper)
if isinstance(element, (PageElement, PageElements)):
# If element is not a page object, update element parent
element.parent = self
def __len__(self):
return len(self.page_elements)
def __getitem__(self, i):
return self.page_elements[i]
def __iter__(self):
return iter(self.page_elements)
class Buttons(PageElements):
page_element_class = Button
class Checkboxes(PageElements):
page_element_class = Checkbox
class InputRadios(PageElements):
page_element_class = InputRadio
class InputTexts(PageElements):
page_element_class = InputText
class Links(PageElements):
page_element_class = Link
class Selects(PageElements):
def __getitem__(self, i):
return self.page_elements[i]
def __iter__(self):
return iter(self.page_elements)
class Buttons(PageElements):
page_element_class = Button
class Checkboxes(PageElements):
page_element_class = Checkbox
class InputRadios(PageElements):
page_element_class = InputRadio
class InputTexts(PageElements):
page_element_class = InputText
class Links(PageElements):
page_element_class = Link
class Selects(PageElements):
page_element_class = Select
class Texts(PageElements):
page_element_class = Checkbox
class InputRadios(PageElements):
page_element_class = InputRadio
class InputTexts(PageElements):
page_element_class = InputText
class Links(PageElements):
page_element_class = Link
class Selects(PageElements):
page_element_class = Select
class Texts(PageElements):
page_element_class = Text
class Groups(PageElements):
page_element_class = Group
return iter(self.page_elements)
class Buttons(PageElements):
page_element_class = Button
class Checkboxes(PageElements):
page_element_class = Checkbox
class InputRadios(PageElements):
page_element_class = InputRadio
class InputTexts(PageElements):
page_element_class = InputText
class Links(PageElements):
page_element_class = Link
class Selects(PageElements):
page_element_class = Select
class Texts(PageElements):
page_element_class = Text
class Groups(PageElements):
page_element.reset_object(self.driver_wrapper)
page_element._web_element = web_element
self._page_elements.append(page_element)
return self._page_elements
def __len__(self):
return len(self.page_elements)
def __getitem__(self, i):
return self.page_elements[i]
def __iter__(self):
return iter(self.page_elements)
class Buttons(PageElements):
page_element_class = Button
class Checkboxes(PageElements):
page_element_class = Checkbox
class InputRadios(PageElements):
page_element_class = InputRadio
class InputTexts(PageElements):
page_element_class = InputText
class Links(PageElements):
def __init__(self, by, value, parent=None, page_element_class=None, order=None):
"""Initialize the PageElements object with the given locator components.
If parent is not None, find_elements will be performed over it, instead of
using the driver's method, so it can find nested elements.
:param by: locator type
:param value: locator value
:param parent: parent element (WebElement, PageElement or locator tuple)
:param order: index value if the locator returns more than one element
:param page_element_class: class of page elements (PageElement, Button...)
:param shadowroot: CSS SELECTOR of JS element where shadowroot tag appears
"""
super(PageElements, self).__init__()
self.locator = (by, value) #: tuple with locator type and locator value
self.parent = parent #: element from which to find actual elements
self.order = order #: index value if the locator returns more than one element
self.shadowroot = None #: Not implemented for PageElements yet
self.driver_wrapper = DriverWrappersPool.get_default_wrapper() #: driver wrapper instance
# update instance element class or use PageElement class
if page_element_class:
self.page_element_class = page_element_class
self._page_elements = []
self.reset_object(self.driver_wrapper)
page_element_class = InputRadio
class InputTexts(PageElements):
page_element_class = InputText
class Links(PageElements):
page_element_class = Link
class Selects(PageElements):
page_element_class = Select
class Texts(PageElements):
page_element_class = Text
class Groups(PageElements):
page_element_class = Group
page_element_class = Button
class Checkboxes(PageElements):
page_element_class = Checkbox
class InputRadios(PageElements):
page_element_class = InputRadio
class InputTexts(PageElements):
page_element_class = InputText
class Links(PageElements):
page_element_class = Link
class Selects(PageElements):
page_element_class = Select
class Texts(PageElements):
page_element_class = Text
class Groups(PageElements):
page_element_class = Group
page_element_class = InputText
class Links(PageElements):
page_element_class = Link
class Selects(PageElements):
page_element_class = Select
class Texts(PageElements):
page_element_class = Text
class Groups(PageElements):
page_element_class = Group