def __init__(self, driver): self.driver = driver self.left_menu = LeftMenu(driver) self.images_table = ImagesTable(driver) self.snapshots_table = SnapshotsTable(driver) self.launch_dialog = LaunchDialog(driver) self.waiter = Waiter(driver, 30, 1)
class ImagesPage: page_url = config.BrowserConfig().browser.horizon_url + \ "/project/images_and_snapshots/" def __init__(self, driver): self.driver = driver self.left_menu = LeftMenu(driver) self.images_table = ImagesTable(driver) self.snapshots_table = SnapshotsTable(driver) self.launch_dialog = LaunchDialog(driver) self.waiter = Waiter(driver, 30, 1) def get(self): self.driver.get(self.page_url) def launch_instance_from_image(self, image_name, instance_name, flavor, script=None): self.images_table.click_launch_item(image_name) self.launch_dialog.launch_instance(None, None, instance_name, flavor, script) self.waiter.wait_until_page_changed(self.page_url) def launch_instance_from_snapshot(self, snapshot_name, instance_name, flavor, script=None): self.snapshots_table.click_launch_item(snapshot_name) self.launch_dialog.launch_instance(None, None, instance_name, flavor, script) self.waiter.wait_until_page_changed(self.page_url) def delete_snapshot_using_actions(self, name): self.snapshots_table.delete_snapshot_using_actions(name) def delete_snapshot(self, name): self.snapshots_table.delete_item(name) def delete_snapshots(self, names): self.snapshots_table.delete_items(names)
def wait_for_visible(cls, driver): """ This method waits until Launch dialog becomes visible """ waiter = Waiter(driver, 20, 1) waiter.wait_until_exist_by_id(LaunchDialog.instance_source_id) waiter.wait_until_visible_by_id(LaunchDialog.instance_source_id)
class ImagesPage: page_url = config.BrowserConfig().browser.horizon_url + \ "/project/images_and_snapshots/" def __init__(self, driver): self.driver = driver self.left_menu = LeftMenu(driver) self.images_table = ImagesTable(driver) self.snapshots_table = SnapshotsTable(driver) self.launch_dialog = LaunchDialog(driver) self.waiter = Waiter(driver, 30, 1) def get(self): self.driver.get(self.page_url) def launch_instance_from_image( self, image_name, instance_name, flavor, script=None): self.images_table.click_launch_item(image_name) self.launch_dialog.launch_instance( None, None, instance_name, flavor, script) self.waiter.wait_until_page_changed(self.page_url) def launch_instance_from_snapshot( self, snapshot_name, instance_name, flavor, script=None): self.snapshots_table.click_launch_item(snapshot_name) self.launch_dialog.launch_instance( None, None, instance_name, flavor, script) self.waiter.wait_until_page_changed(self.page_url) def delete_snapshot_using_actions(self, name): self.snapshots_table.delete_snapshot_using_actions(name) def delete_snapshot(self, name): self.snapshots_table.delete_item(name) def delete_snapshots(self, names): self.snapshots_table.delete_items(names)
class ConfirmationDialog(object): confirm_popup_css = "div.modal.hide.in" confirm_button_css = "#modal_wrapper a.btn.btn-primary" def __init__(self, driver): self.driver = driver self.waiter = Waiter(driver, 30, 1) def wait_for_visible(self): """ This method waits until Launch dialog becomes visible """ self.waiter.wait_until_exist_by_css(self.confirm_button_css) self.waiter.wait_until_visible_by_css(self.confirm_button_css) def click_submit(self): self.driver.find_element_by_css_selector( self.confirm_button_css).click() self.waiter.wait_until_not_exist_by_css(self.confirm_popup_css)
class MoreActionsDropdown(object): more_link_css = "a.dropdown-toggle" root_css = "ul.dropdown-menu" edit_action_css = "a[id*='action_edit']" view_log_action_css = "a[id*='action_log']" reboot_action_css = "button[id*='action_reboot']" terminate_action_css = "button[id*='action_terminate']" delete_action_css = "button[id*='action_delete']" def __init__(self, driver, parent_css): self.driver = driver self.waiter = Waiter(driver, 20, 1) self.parent_css = parent_css self.confirm = ConfirmationDialog(self.driver) def wait_for_visible(self): """ This method waits until More actions dropdown becomes visible """ self.waiter.wait_until_visible_by_css(self.parent_css + ' ' + self.root_css) def open_dropdown(self): button_class = self.driver.find_element_by_css_selector( self.parent_css).find_element_by_css_selector( self.more_link_css).find_element_by_xpath('..').get_attribute( 'class') if not 'open' in button_class: self.driver.find_element_by_css_selector( self.parent_css).find_element_by_css_selector( self.more_link_css).click() self.wait_for_visible() def click_edit(self): self.open_dropdown() self.driver.find_element_by_css_selector( self.parent_css).find_element_by_css_selector( self.edit_action_css).click() self.confirm.wait_for_visible() def click_view_log(self): current_url = self.driver.current_url self.open_dropdown() self.driver.find_element_by_css_selector( self.parent_css).find_element_by_css_selector( self.view_log_action_css).click() self.waiter.wait_until_page_changed(current_url) def click_reboot(self): self.open_dropdown() self.driver.find_element_by_css_selector( self.parent_css).find_element_by_css_selector( self.reboot_action_css).click() self.confirm.wait_for_visible() def click_terminate(self): self.open_dropdown() self.driver.find_element_by_css_selector( self.parent_css).find_element_by_css_selector( self.terminate_action_css).click() self.confirm.wait_for_visible() def click_delete(self): self.open_dropdown() self.driver.find_element_by_css_selector( self.parent_css).find_element_by_css_selector( self.delete_action_css).click() self.confirm.wait_for_visible()
def __init__(self, driver, parent_css): self.driver = driver self.waiter = Waiter(driver, 20, 1) self.parent_css = parent_css self.confirm = ConfirmationDialog(self.driver)
def __init__(self, driver, root_css=None): self.driver = driver self.waiter = Waiter(driver, 20, 1) if root_css: self.root_css = root_css
class LaunchDialog(object): root_css = "div.workflow.modal.hide.in.dropdown_fix" instance_source_id = 'id_source_type' image_id = 'id_image_id' snapshot_id = 'id_instance_snapshot_id' instance_name_id = 'id_name' flavor_id = 'id_flavor' launch_button_css = "input.btn.btn-primary.pull-right" user_data_link_css = 'a[href="#launch_instance__customizeaction"]' custom_script_id = "id_customization_script" def __init__(self, driver, root_css=None): self.driver = driver self.waiter = Waiter(driver, 20, 1) if root_css: self.root_css = root_css @classmethod def wait_for_visible(cls, driver): """ This method waits until Launch dialog becomes visible """ waiter = Waiter(driver, 20, 1) waiter.wait_until_exist_by_id(LaunchDialog.instance_source_id) waiter.wait_until_visible_by_id(LaunchDialog.instance_source_id) def select_instance_source(self, source=InstanceSource.IMAGE): select = Select( self.driver.find_element_by_id(self.instance_source_id)) select.select_by_value(source) def select_image(self, image_name='Select Image'): select = Select( self.driver.find_element_by_id(self.image_id)) select.select_by_visible_text(image_name) def select_snapshot(self, snapshot_name='Select Instance Snapshot'): select = Select( self.driver.find_element_by_id(self.snapshot_id)) select.select_by_visible_text(snapshot_name) def set_instance_name(self, name): self.driver.find_element_by_id(self.instance_name_id).send_keys(name) def select_flavor(self, flavor_name): select = Select( self.driver.find_element_by_id(self.flavor_id)) select.select_by_visible_text(flavor_name) def set_user_script(self, script): self.driver.find_element_by_css_selector( self.root_css).find_element_by_css_selector( self.user_data_link_css).click() scr_str = "$('#" + self.custom_script_id + "').val('" + script.replace( '\n', '\\n') + "')" self.driver.execute_script(scr_str) def submit_form(self): self.driver.find_element_by_css_selector( self.root_css).find_element_by_css_selector( self.launch_button_css).click() self.waiter.wait_until_not_exist_by_css(self.root_css) def launch_instance( self, instance_source, image, instance_name, flavor, script): if instance_source: self.select_instance_source(instance_source) if (instance_source == InstanceSource.IMAGE): if image: self.select_image(image) elif (instance_source == InstanceSource.SNAPSHOT): if image: self.select_snapshot(image) self.set_instance_name(instance_name) self.select_flavor(flavor) if script: self.set_user_script(script) self.submit_form()
class MoreActionsDropdown(object): more_link_css = "a.dropdown-toggle" root_css = "ul.dropdown-menu" edit_action_css = "a[id*='action_edit']" view_log_action_css = "a[id*='action_log']" reboot_action_css = "button[id*='action_reboot']" terminate_action_css = "button[id*='action_terminate']" delete_action_css = "button[id*='action_delete']" def __init__(self, driver, parent_css): self.driver = driver self.waiter = Waiter(driver, 20, 1) self.parent_css = parent_css self.confirm = ConfirmationDialog(self.driver) def wait_for_visible(self): """ This method waits until More actions dropdown becomes visible """ self.waiter.wait_until_visible_by_css( self.parent_css + ' ' + self.root_css) def open_dropdown(self): button_class = self.driver.find_element_by_css_selector( self.parent_css).find_element_by_css_selector( self.more_link_css).find_element_by_xpath( '..').get_attribute('class') if not 'open' in button_class: self.driver.find_element_by_css_selector( self.parent_css).find_element_by_css_selector( self.more_link_css).click() self.wait_for_visible() def click_edit(self): self.open_dropdown() self.driver.find_element_by_css_selector( self.parent_css).find_element_by_css_selector( self.edit_action_css).click() self.confirm.wait_for_visible() def click_view_log(self): current_url = self.driver.current_url self.open_dropdown() self.driver.find_element_by_css_selector( self.parent_css).find_element_by_css_selector( self.view_log_action_css).click() self.waiter.wait_until_page_changed(current_url) def click_reboot(self): self.open_dropdown() self.driver.find_element_by_css_selector( self.parent_css).find_element_by_css_selector( self.reboot_action_css).click() self.confirm.wait_for_visible() def click_terminate(self): self.open_dropdown() self.driver.find_element_by_css_selector( self.parent_css).find_element_by_css_selector( self.terminate_action_css).click() self.confirm.wait_for_visible() def click_delete(self): self.open_dropdown() self.driver.find_element_by_css_selector( self.parent_css).find_element_by_css_selector( self.delete_action_css).click() self.confirm.wait_for_visible()
def __init__(self, driver, timeout=30, poll_period=2): self.driver = driver self.waiter = Waiter(self.driver, timeout, poll_period)
def __init__(self, driver): self.driver = driver self.waiter = Waiter(driver, 30, 1)