class AbstractDialog(AbstractView):
    XPATH_DIALOG = "/html/body/div[contains(@class,'modal ')]"

    BUTTON_APPLY = "Apply"
    BUTTON_CREATE = "Create"
    BUTTON_CANCEL = "Cancel"
    BUTTON_DELETE = "Delete"
    BUTTON_DEPLOY = "Deploy"

    def __init__(self):
        self.wait_loading()

        self.elementClose = Button(
            xpath="./div[@class='modal-header']/button[@class='close']",
            element_name="Dialog [x] header icon"
        )
        self.footerButton = Button(
            xpath="./div[@class='modal-footer']/button[contains(.,'{name}')]",
            element_name="Dialog footer button [{name}]"
        )

        AbstractView.__init__(self, self.__get_control_dialog())

    @classmethod
    def __get_control_dialog(cls):
        return cls.get_wait_bot().wait_for_web_element(
            By.XPATH, cls.XPATH_DIALOG)

    def apply(self):
        return self.click_footer_button(self.BUTTON_APPLY)

    def cancel(self):
        return self.click_footer_button(self.BUTTON_CANCEL)

    def click_footer_button(self, name):
        res = self.footerButton.find(name=name).click_and_wait()
        self.wait_closing()
        return res

    def close(self):
        return self.elementClose.click_and_wait()

    def create(self):
        return self.click_footer_button(self.BUTTON_CREATE)

    def delete(self):
        return self.click_footer_button(self.BUTTON_DELETE)

    def deploy(self):
        return self.click_footer_button(self.BUTTON_DEPLOY)

    def wait_closing(self):
        self.get_wait_bot().wait_for_disappears(By.XPATH, self.XPATH_DIALOG)
        self.get_wait_bot().wait_loading()

    def wait_loading(self):
        self.get_wait_bot().wait_for_stop_moving(By.XPATH, self.XPATH_DIALOG)
        self.get_wait_bot().wait_loading()
示例#2
0
class Releases_Table(Table):

    def __init__(self):
        self.configure = Button(
            xpath="./tbody/tr[{row}]/td[{column}]/button",
            element_name="Configure"
        )
        self.progress = HtmlElement(
            xpath="./tbody/tr[{row}]/td[{column}]"
                  "//div[contains(@class, 'progress')]",
            element_name="progress bar"
        )
        Table.__init__(self, HtmlElement(
            xpath=".//table[contains(@class, 'releases-table')]",
            element_name="Releases table"
        ).get_element())

    def get_release_row(self, release_name):
        return self.get_row(1, release_name)

    def get_release_status(self, release_name):
        return self.get_value(self.get_release_row(release_name), 3)

    def click_configure(self, release_name):
        return self.configure.find(
            row=self.get_row(1, release_name),
            column=4
        ).click()

    def verify_releases_count(self, count):
        return self.get_verify_bot().verify_equal(
            count, self.get_rows_count(), "Releases table", "rows count"
        )

    def verify_release_status(self, release_name, status):
        return self.get_verify_bot().verify_equal(
            expected=status,
            actual=self.get_release_status(release_name),
            name=release_name,
            _type="status"
        )

    def wait_downloading(self, release_name):
        rl = ResultList(
            "Wait release downloading done: {}".format(release_name))
        row = self.get_release_row(release_name=release_name)
        rl.push(self.progress.find(row=row, column=3).verify_visible(True))
        rl.info("Release download started")
        if self.get_wait_bot().wait_for_web_element_disappears(
                web_element=self.progress.get_element(),
                timeout=20,
                poll_frequency=3) is not None:
            rl.info("Release download done")
        else:
            rl.push(Result("Release download failed on timeout", False))
        return rl
示例#3
0
class AbstractDialog(AbstractView):
    XPATH_DIALOG = "/html/body/div[contains(@class,'modal ')]"

    BUTTON_APPLY = "Apply"
    BUTTON_CREATE = "Create"
    BUTTON_CANCEL = "Cancel"
    BUTTON_DELETE = "Delete"
    BUTTON_DEPLOY = "Deploy"
    BUTTON_NEXT = "Next >"
    BUTTON_PREV = "< Prev"

    def __init__(self):
        self.wait_loading()

        self.elementClose = Button(
            xpath="./div[@class='modal-header']/button[@class='close']",
            element_name="Dialog [x] header icon")
        self.footerButton = Button(
            xpath=".//div[contains(@class,'modal-footer')]"
            "/button[contains(.,'{name}')]",
            element_name="Dialog footer button [{name}]")

        AbstractView.__init__(self, self.__get_control_dialog())

    @classmethod
    def __get_control_dialog(cls):
        return cls.get_wait_bot().wait_for_web_element(By.XPATH,
                                                       cls.XPATH_DIALOG)

    def apply(self):
        return self.click_footer_button(self.BUTTON_APPLY)

    def cancel(self):
        return self.click_footer_button(self.BUTTON_CANCEL)

    def click_footer_button(self, name, wait_closing=True):
        res = self.footerButton.find(name=name).click_and_wait()
        if wait_closing:
            self.wait_closing()
        return res

    def close(self):
        return self.elementClose.click_and_wait()

    def create(self):
        return self.click_footer_button(self.BUTTON_CREATE)

    def delete(self):
        return self.click_footer_button(self.BUTTON_DELETE)

    def deploy(self):
        return self.click_footer_button(self.BUTTON_DEPLOY)

    def deploy_button(self):
        return self.footerButton.find(name=self.BUTTON_DEPLOY)

    def clickNext(self, wait_closing=False):
        return self.click_footer_button(self.BUTTON_NEXT, wait_closing)

    def clickPrev(self):
        return self.click_footer_button(self.BUTTON_PREV, False)

    def wait_closing(self):
        self.get_wait_bot().wait_for_disappears(By.XPATH, self.XPATH_DIALOG)
        self.get_wait_bot().wait_loading()

    def wait_loading(self):
        self.get_wait_bot().wait_for_stop_moving(By.XPATH, self.XPATH_DIALOG)
        self.get_wait_bot().wait_for_stop_resizing(By.XPATH, self.XPATH_DIALOG)
        self.get_wait_bot().wait_loading()