示例#1
0
    def __init__(self, locator):
        """
        Constructor to initialize web driver, locator and waiting

        :param locator: locator for element
        """
        self.driver = Browser().get_driver()
        self.locator = locator
        self.wait = CustomWaitings()
示例#2
0
 def find_element_not_clickable(self):
     """
     method to look for element
     """
     return CustomWaitings().error_wait().until_not(
         EC.element_to_be_clickable(self.locator),
         message=f"Can't find element by locator {self.locator}")
示例#3
0
 def find_element_not_visibility(self):
     """
     method to look for element
     """
     return CustomWaitings().error_wait().until_not(
         EC.visibility_of_element_located(self.locator),
         message=f"Can't find element by locator {self.locator}")
示例#4
0
class BaseElement:
    """
    Class for base element
    """
    def __init__(self, locator):
        """
        Constructor to initialize web driver, locator and waiting

        :param locator: locator for element
        """
        self.driver = Browser().get_driver()
        self.locator = locator
        self.wait = CustomWaitings()

    def find_element_located(self):
        """
        method to look for element by locator
        """
        return self.wait.fluent_wait().until(EC.presence_of_element_located(self.locator),
                                        message=f"Can't find element by locator {self.locator}")

    def find_elements_located(self):
        """
        method to look for elements by locator
        """
        return self.wait.fluent_wait().until(EC.presence_of_all_elements_located(self.locator),
                                        message=f"Can't find elements by locator {self.locator}")

    def hover(self):
        """
        method to hover element by locator
        """
        target = self.find_element_located()
        y_position = 0
        searching = True
        while searching:
            try:
                ActionChains(self.driver).move_to_element(target).perform()
                searching = False
            except MoveTargetOutOfBoundsException:
                y_position += 500
                self.driver.execute_script('window.scrollTo(0, ' + str(y_position) + ');')
示例#5
0
 def switch_to_frame(self):
     return CustomWaitings().fluent_wait().until(EC.frame_to_be_available_and_switch_to_it(self.locator),
                                                 message=f"Can't find element by locator {self.locator}")
示例#6
0
 def find_element_present_text(self, text):
     logger = logging.getLogger(__name__)
     logger.info(f'Looking for element with locator {self.locator}')
     return CustomWaitings().fluent_wait().until(
         EC.text_to_be_present_in_element(self.locator, text),
         message=f"Can't find element by locator {self.locator}")