Ejemplo n.º 1
0
class LoginPage():
    def __init__(self):
        self._cbb_repository = ComboBox("name=repository")
        self._txt_username = TextBox("id=username")
        self._txt_password = TextBox("id=password")
        self._btn_login = BaseElement("class=btn-login")

    def open(self):
        browser.open_url(os.getenv("url"))
        browser.wait_until(have.title(constant.DA_TITLE))

    def login(self,
              username=constant.DA_USER,
              password=constant.DA_PWD,
              success=True,
              repository=constant.DA_REPO):
        self._cbb_repository.select_by_visible_text(repository)
        self._txt_username.clear()
        self._txt_username.send_keys(username)
        self._txt_password.send_keys(password)
        self._btn_login.click()
        if success:
            self._btn_login.wait_for_invisible()

    def is_message_displayed(self, message):
        return browser_helper.get_alert_text() == message
Ejemplo n.º 2
0
class DashboardPage():

    def __init__(self):
        self._lbl_login_title = BaseElement("//div[@class='ltext' and text()='Login']")
        self._lbl_welcome_user = BaseElement("//a[@href='#Welcome']")
        self._lbl_logout = BaseElement("//a[@href='logout.do']")
        self._ico_global_setting = BaseElement("//li[@class='mn-setting']/a")
        self._txt_page_name = TextBox("id=name")
        self._cbb_parent_name = ComboBox("id=parent")
        self._cbb_num_of_column = ComboBox("id=columnnumber")
        self._cbb_display_after = ComboBox("id=afterpage")
        self._cb_public = BaseElement("id=ispublic")
        self._btn_dynamic_on_add_edit_new_page = BaseElement("//input[@class='button page_button' and @id='%s']")
        self._lbl_test_module_execution = BaseElement("//div[@title='Test Module Execution']")
        self._lbl_dynamic_global_setting_item = BaseElement("//li[@class='mn-setting']//a[text()='%s']")
        self._lbl_dynamic_label = BaseElement("//a[text()='%s']")
        self._lbl_administer_user = BaseElement("//a[@href='#Administer']")

    def logout(self):
        self._lbl_welcome_user.wait_for_visible()
        self._lbl_welcome_user.move_to()
        self._lbl_logout.wait_for_visible()
        self._lbl_logout.click()
        self._lbl_welcome_user.wait_for_invisible()

    def add_page(self, page_name, parent_page = "Overview", success=True):
        self.select_global_selecting_item("Add Page")
        self.fill_page_info(page_name, parent_page)
        self.submit_modal()
        if success:
            self._txt_page_name.wait_for_invisible()
        
    def edit_page(self,page_name, parent_page = "Overview", success=True):
        self.select_global_selecting_item("Edit")
        self.fill_page_info(page_name, parent_page)
        self.submit_modal()
        if success:
            self._txt_page_name.wait_for_invisible()
        
    def submit_modal(self):
        self._btn_dynamic_on_add_edit_new_page.format("OK")
        self._btn_dynamic_on_add_edit_new_page.wait_for_visible()
        self._btn_dynamic_on_add_edit_new_page.click()
    
    def dismiss_modal(self):
        self._btn_dynamic_on_add_edit_new_page.format("Cancel")
        if self._btn_dynamic_on_add_edit_new_page.is_displayed(SHORT_TIME):
            self._btn_dynamic_on_add_edit_new_page.click()
        self._btn_dynamic_on_add_edit_new_page.wait_for_invisible()
        
    def fill_page_info(self,page_name, parent_page = "Overview"):
        self._txt_page_name.wait_for_visible()
        self._txt_page_name.clear()
        self._txt_page_name.send_keys(page_name)
        self._cbb_parent_name.wait_for_visible()
        self._cbb_parent_name.select_by_text_contains(parent_page)
           
    def select_global_selecting_item(self, item):
        self._ico_global_setting.wait_for_visible()
        self._ico_global_setting.click()
        self._lbl_dynamic_global_setting_item.format(item)
        self._lbl_dynamic_global_setting_item.wait_for_visible()
        self._lbl_dynamic_global_setting_item.click()
        
    def open_page(self,*page_name):
        for item in page_name:
            self._lbl_dynamic_label.format(item)
            self._lbl_dynamic_label.wait_for_visible()
            if item == page_name[-1]:
                self._lbl_dynamic_label.click()
            else:
                self._lbl_dynamic_label.move_to()
    
    def delete_page(self, page_name):
        self.open_page(*page_name)
        self.select_global_selecting_item("Delete")
        browser_helper.accept_alert()
        self._lbl_test_module_execution.wait_for_visible()

    def click_administer_item(self, item):
        self._lbl_administer_user.wait_for_visible()
        self._lbl_administer_user.move_to()
        self._lbl_dynamic_label.format(item)
        self._lbl_dynamic_label.wait_for_visible()
        self._lbl_dynamic_label.click()