class DashBoardLoginPage(): _txt_user_name = TextBox("id=username") _txt_pass_word = TextBox("id=password") _btn_log_in = BaseElement("class=btn-login") def __init__(self): pass def open_ta_dashboard(self): browser.open_url("http://localhost:8088/TADashboard/login.jsp") #browser.wait_until(have.title("Google")) def login(self, user_name, pass_word): # self._txt_search.wait_for_visible() self._txt_user_name.wait_until(be.visible) self._txt_user_name.send_keys(user_name) self._txt_user_name.wait_until(have.value(user_name)) self._txt_pass_word.wait_until(be.visible) self._txt_pass_word.send_keys(pass_word) self._txt_pass_word.wait_until(have.value(pass_word)) self._btn_log_in.click() def _check_invalid_message(self): alert_obj = browser.get_driver().switch_to.alert strAlert = alert_obj.text print("Alert shows following message: " + strAlert) time.sleep(2) alert_obj.accept() print(" Clicked on the OK Button in the Alert Window") browser.get_driver().close return strAlert
def __init__(self): self._btn_next = Button("css=input[value='Next']") self._btn_finish = Button("css=input[value='Finish']") self._btn_cancel = Button("css=input[value='Cancel']") self._txt_name = TextBox("id=txtProfileName") self._cbb_item_type = ComboBox("id=cbbEntityType") self._cbb_related_data = ComboBox("id=cbbSubReport")
class GeneralSettingPage(GeneralPage): def __init__(self): self._btn_next = Button("css=input[value='Next']") self._btn_finish = Button("css=input[value='Finish']") self._btn_cancel = Button("css=input[value='Cancel']") self._txt_name = TextBox("id=txtProfileName") self._cbb_item_type = ComboBox("id=cbbEntityType") self._cbb_related_data = ComboBox("id=cbbSubReport") def next(self): self._btn_next.wait_for_visible() self._btn_next.click() def finish(self): self._btn_finish.wait_for_visible() self._btn_finish.click() def cancel(self): self._btn_cancel.wait_for_visible() self._btn_cancel.click() def enter_profile_information(self, name, item_type = None, related_data = None): self._txt_name.wait_for_visible() self._txt_name.send_keys(name) if item_type is not None: self._cbb_item_type.select_by_text_contains(item_type) if related_data is not None: self._cbb_related_data.select_by_text_contains(related_data) def add_new_profile(self, name, item_type = None, related_data = None): self.enter_profile_information(name, item_type, related_data) self.finish()
def __init__(self): self._btn_global_setting = BaseElement("class=mn-setting") self._txt_page_name = TextBox("id=name") self._cbb_parent_name = ComboBox("id=parent") self._btn_ok = BaseElement("id=OK") self._lbl_test_module_execution = BaseElement( "//div[@title='Test Module Execution']") self._link_page_item = BaseElement( "//div[@id='main-menu']//a[text()='%s']") self._item_menu = BaseElement("//a[text()='%s']")
def __init__(self): super().__init__() self._mnu_administer = Menu("css=[href='#Administer']") self._mmu_global_setting = Menu("css=.mn-setting") self._mnu_overview = Menu("//div[@id='main-menu']//a[text()='Overview']") self._lbl_new_page_title = Label("css=#div_popup h2") self._txt_name = TextBox("css=#div_popup #name") self._cbb_parent = ComboBox("css=#div_popup #parent") self._cbb_number_of_column = ComboBox("css=#div_popup #columnnumber") self._cbb_display_after = ComboBox("css=#div_popup #afterpage") self._chk_is_public = CheckBox("css=#div_popup #ispublic") self._btn_ok = Button("css=#div_popup #OK") self._btn_cancel = Button("css=#div_popup #Cancel")
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']")
class TestArchitectLoginPage(): _txt_username = TextBox("id=username") _txt_password = TextBox("id=password") _btn_login = BaseElement("xpath=//div[@class='btn-login']") _combox_repository = ComboBox("id=repository") _str_title = "TestArchitect" def login(self, username, password, repository): browser.wait_until(have.title(self._str_title)) self._combox_repository.select_by_value(repository) self._txt_username.clear_text() self._txt_username.send_keys(username) self._txt_password.clear_text() self._txt_password.send_keys(password) self._btn_login.click()
class DAGeneralSettingsPage(): def __init__(self): self.dynamic_button = BaseElement("//input[@value='%s']") self._txt_name = TextBox("id=txtProfileName") self._cbb_type = ComboBox("id=cbbEntityType") self._cbb_related_data = ComboBox("id=cbbSubReport") def fill_general_setting_info(self, name, item_type=None, related_data=None): self._txt_name.wait_for_visible() self._txt_name.clear() self._txt_name.send_keys(name) if item_type is not None: self._cbb_type.select_by_visible_text(item_type) if related_data is not None: self._cbb_related_data.select_by_visible_text(related_data) def click_next_button(self): self.dynamic_button.format("Next") self.dynamic_button.wait_for_visible() self.dynamic_button.click() def click_finish_button(self): self.dynamic_button.format("Finish") self.dynamic_button.wait_for_visible() self.dynamic_button.click() def get_item_type_options(self): return self._cbb_type.get_options()
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
class LoginPage(): _txt_username = TextBox("id=username") _txt_password = TextBox("id=password") _btn_login = BaseElement("class=btn-login") def __init__(self): pass def open_login_page(self): browser.open_url("http://192.168.188.99/TADashboard/login.jsp") def login(self, username, password): self._txt_username.wait_until(be.visible) self._txt_username.send_keys(username) self._txt_password.send_keys(password) self._btn_login.click() self._txt_username.wait_for_invisible(10) def get_alert_msg(self): diaglog = self._driver.switch_to.alert msg = diaglog.text return msg
class GoogleHomePage(): _txt_search = TextBox("name=q") def __init__(self): pass def open_google(self): browser.open_url("https://google.com") browser.wait_until(have.title("Google")) def search(self, key_word): # self._txt_search.wait_for_visible() self._txt_search.wait_until(be.visible) self._txt_search.send_keys(key_word) self._txt_search.wait_until(have.value(key_word))
class DashBoardHomePage(): _txt_search = TextBox("name=q") _icon_global_setting = BaseElement("class=.mn-setting") def __init__(self): pass def select_global_setting(self, setting): self._icon_global_setting.click() self.find_element() def search(self, key_word): # self._txt_search.wait_for_visible() self._txt_search.wait_until(be.visible) self._txt_search.send_keys(key_word) self._txt_search.wait_until(have.value(key_word))
class TestArchitectProfilePage(): _txt_name_profile = TextBox("id=txtProfileName") _cbo_item_type = ComboBox("id=cbbEntityType") _cb_related_data = ComboBox("id=cbbSubReport") dynamic_string = "//input[@value='{}']" def create_profile(self, profile_name, item_type=None, related_data=None): self._txt_name_profile.clear_text() self._txt_name_profile.send_keys(profile_name) if item_type != None: self._cbo_item_type.select_by_visible_text(item_type) if related_data != None: self._cb_related_data.select_by_visible_text(related_data) def click_button(self, button_name): browser.wait_for_page_load_by_ajax() _btn_button_name = BaseElement(self.dynamic_string.format(button_name)) _btn_button_name.wait_for_clickable(constant.MEDIUM_TIME_OUT / 6) _btn_button_name.click() def get_all_options_item_type(self): self._cbo_item_type.click() browser.wait_for_page_load_by_ajax() items = self._cbo_item_type.options() list_items = [] for item in items: list_items.append(item.text) return list_items def do_items_exist(self, list_data): result = all(elem in list_data for elem in self.get_all_options_item_type()) return result
class LoginPage(): data = DataReader() def __init__(self): self._txt_user_name = TextBox("id=username") self._txt_password = TextBox("id=password") self._btn_login = Button("css=.btn-login") def go_to(self): browser.open_url(self.data.get_url()) self._txt_user_name.wait_for_visible() def login(self, user=data.get_username(), pwd=data.get_password()): self._txt_user_name.send_keys(user) self._txt_password.send_keys(pwd) self._btn_login.click() browser_helper.wait_for_ajax()
def __init__(self): self.dynamic_button = BaseElement("//input[@value='%s']") self._txt_name = TextBox("id=txtProfileName") self._cbb_type = ComboBox("id=cbbEntityType") self._cbb_related_data = ComboBox("id=cbbSubReport")
class TestArchitectNewPage(TestArchitectHomePage): _txt_title = BaseElement( "xpath=//div[@id='div_popup']//h2[text()='New Page']") _txt_page_name = TextBox("id=name") _cbo_parent_page = ComboBox("id=parent") _bnt_ok = Button("id=OK") _bnt_cancel = Button("id=Cancel") _chk_public = CheckBox("id=ispublic") _str_delete_page = "Delete" _str_edit_page = "Edit" def select_combox_menu(self, item): self._txt_title.wait_until(be.visible) self._cbo_parent_page.select_by_visible_text(item) def fill_on_fields(self, name_page, parent_page=None, number_of_page=None, display_after=None, check=None): self._txt_page_name.clear_text() self._txt_page_name.send_keys(name_page) self._txt_page_name.wait_until(have.value(name_page)) if parent_page != None: self.select_parent_dropdown(parent_page) if number_of_page != None: self.select_combox_menu(number_of_page) if display_after != None: self.select_combox_menu(display_after) if check != None: self._chk_public.click() def add_new_page(self, name_page, parent_page=None, number_of_col=None, display_after=None, public_check=None): self.fill_on_fields(name_page, parent_page, number_of_col, display_after, public_check) self._bnt_ok.wait_for_clickable(constant.MEDIUM_TIME_OUT / 6) self._bnt_ok.click() def go_to_edit_page(self): TestArchitectHomePage.select_menu(self, self._str_edit_page) def go_to_delete_page(self): TestArchitectHomePage.select_menu(self, self._str_delete_page) def edit_page(self, name_page, parent_page=None, number_of_col=None, display_after=None, public_check=None): self.fill_on_fields(name_page, parent_page, number_of_col, display_after, public_check) self._bnt_ok.wait_for_clickable(constant.MEDIUM_TIME_OUT / 5) self._bnt_ok.click() def delete_page(self, page_path): TestArchitectHomePage.go_to_page(self, page_path) TestArchitectHomePage.go_to_global_setting(self) self.go_to_delete_page() browser.accept_alert() def get_title_page(self): browser.wait_for_page_load_by_ajax() title = browser.get_title() spl_title = title.split("-") title = spl_title[-1] return title.strip() def cancel_page(self): self._bnt_cancel.wait_for_clickable(constant.MEDIUM_TIME_OUT / 5) self._bnt_cancel.click() def select_parent_dropdown(self, item): self._cbo_parent_page.click() browser.wait_for_page_load_by_ajax() elements = self._cbo_parent_page.options() for element in elements: if element.text.strip() == item: element.click() break
class DashboardPage(GeneralPage): def __init__(self): super().__init__() self._mnu_administer = Menu("css=[href='#Administer']") self._mmu_global_setting = Menu("css=.mn-setting") self._mnu_overview = Menu("//div[@id='main-menu']//a[text()='Overview']") self._lbl_new_page_title = Label("css=#div_popup h2") self._txt_name = TextBox("css=#div_popup #name") self._cbb_parent = ComboBox("css=#div_popup #parent") self._cbb_number_of_column = ComboBox("css=#div_popup #columnnumber") self._cbb_display_after = ComboBox("css=#div_popup #afterpage") self._chk_is_public = CheckBox("css=#div_popup #ispublic") self._btn_ok = Button("css=#div_popup #OK") self._btn_cancel = Button("css=#div_popup #Cancel") def select_global_setting_option(self, option): self._mmu_global_setting.wait_for_visible() self._mmu_global_setting.select_menu(option) def select_page(self, *link): self._mnu_overview.wait_for_visible() self._mnu_overview.select_menu(*link) def delete_page(self, *page_link): self.select_page(*page_link) self.select_global_setting_option(MenuList.DELETE.value) browser_helper.accept_alert() self._mmu_global_setting.wait_for_visible() def add_new_page(self, name, parent = None, succeed = True): self.select_global_setting_option(MenuList.ADD_PAGE.value) self.enter_new_page_information(name, parent) self.submit_modal() if succeed: self._lbl_new_page_title.wait_for_invisible() def edit_page(self, name, parent = None, succeed = True): self.select_global_setting_option(MenuList.EDIT.value) self.enter_new_page_information(name, parent) self.submit_modal() if succeed: self._lbl_new_page_title.wait_for_invisible() def enter_new_page_information(self, name, parent): self._lbl_new_page_title.wait_for_visible() self._txt_name.clear() self._txt_name.send_keys(name) if parent is not None: self._cbb_parent.select_by_text_contains(parent) def submit_modal(self): self._btn_ok.wait_for_visible() self._btn_ok.click() def cancel_modal(self): self._btn_cancel.wait_for_visible() self._btn_cancel.click() def select_administer_option(self, option): self._mnu_administer.wait_for_visible() self._mnu_administer.select_menu(option)
def __init__(self): self._txt_user_name = TextBox("id=username") self._txt_password = TextBox("id=password") self._btn_login = Button("css=.btn-login")
class DashboardPage(): def __init__(self): self._btn_global_setting = BaseElement("class=mn-setting") self._txt_page_name = TextBox("id=name") self._cbb_parent_name = ComboBox("id=parent") self._btn_ok = BaseElement("id=OK") self._lbl_test_module_execution = BaseElement( "//div[@title='Test Module Execution']") self._link_page_item = BaseElement( "//div[@id='main-menu']//a[text()='%s']") self._item_menu = BaseElement("//a[text()='%s']") def page_title(self, title): return constant.DA_TITLE + " - " + title def is_page_displayed(self, page_name): return browser_helper.get_title() == self.page_title(page_name) def select_menu_item(self, *menu_item): for item in menu_item: self._item_menu.format(item) self._item_menu.wait_for_visible() if item == menu_item[-1]: self._item_menu.click() else: self._item_menu.move_to() def log_out(self): self.select_menu_item(constant.DA_USER, MenuList.LOGOUT.value) def select_global_setting(self, name): self._btn_global_setting.wait_for_visible() self._btn_global_setting.move_to() self.select_menu_item(name) def fill_page_info(self, page_name, parent_name): self._txt_page_name.wait_for_visible() self._txt_page_name.clear() self._txt_page_name.send_keys(page_name) if parent_name is not None: self._cbb_parent_name.select_by_text_contains(parent_name) def create_new_page(self, page_name, parent_name=constant.ROOT_PAGE, success=True): self.select_global_setting(SettingsList.ADD_PAGE.value) self.fill_page_info(page_name, parent_name) self._btn_ok.wait_for_visible() self._btn_ok.click() if success: self._txt_page_name.wait_for_invisible() def edit_page_info(self, page_name, parent_name=None, success=True): self.select_global_setting(SettingsList.EDIT.value) self.fill_page_info(page_name, parent_name) self._btn_ok.wait_for_visible() self._btn_ok.click() if success: self._txt_page_name.wait_for_invisible() def go_to_page(self, *page_name): self.select_menu_item(*page_name) def delete_page(self, *page_name): self.go_to_page(*page_name) self.select_global_setting(SettingsList.DELETE.value) browser_helper.accept_alert() self._lbl_test_module_execution.wait_for_visible()
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()
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")