示例#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 setup():
    """
    Fixture for implementing setup and teardown
    """
    driver = Browser()
    driver.get_driver()
    driver.get_base_url()
    yield
    driver.quit()
示例#3
0
 def __init__(self):
     """
     Constructor for class
     """
     self.config_settings = ConfigParser().get_config_settings()
     self.f_wait = self.config_settings['fluent_wait_time']
     self.err_wait = self.config_settings['error_wait_time']
     self.poll_frequency = self.config_settings['poll_frequency']
     self.driver = Browser().get_driver()
示例#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 get_text(self):
        """
        method to check text

        :return: text
        """
        Frame(FramePageLocators.LOCATOR_FRAME_PAGE_IFRAME).switch_to_frame()
        text = BlockElement(FramePageLocators.LOCATOR_FRAME_PAGE_TEXT
                            ).find_element_visibility().text
        Browser().switch_to_default_frame()
        return text
示例#6
0
 def do_text_bold(self):
     """
     method to do text bold
     """
     Frame(FramePageLocators.LOCATOR_FRAME_PAGE_IFRAME).switch_to_frame()
     element = BlockElement(FramePageLocators.LOCATOR_FRAME_PAGE_TEXT
                            ).find_element_visibility()
     element.click()
     element.send_keys(Keys.CONTROL + self.settings['KEY_a'])
     Browser().switch_to_default_frame()
     ClickableElement(FramePageLocators.LOCATOR_FRAME_PAGE_BOLD_BUTTON
                      ).find_element_clickable().click()
示例#7
0
    def type_text(self, text):
        """
        method to send random text

        :return: text
        """
        Frame(FramePageLocators.LOCATOR_FRAME_PAGE_IFRAME).switch_to_frame()
        element = BlockElement(FramePageLocators.LOCATOR_FRAME_PAGE_TEXT
                               ).find_element_visibility()
        element.clear()
        element.send_keys(text)
        Browser().switch_to_default_frame()
        return text
示例#8
0
 def __init__(self):
     """
     Constructor for class
     """
     self.driver = Browser().get_driver()