def delete_file(self, filename, confirm=True): """ Delete `filename`. """ self('files_tab').click() element = self.find_file(filename) chain = ActionChains(self.browser) chain.context_click(element).perform() time.sleep(0.5) self('file_delete').click() time.sleep(0.5) page = ConfirmationPage(self) if confirm: page.click_ok() else: page.click_cancel()
def replace(self, name, classname, confirm=True): """ Replace `name` with an instance of `classname`. """ library_item = self.get_library_item(classname) target = self.get_dataflow_figure(name).root chain = ActionChains(self.browser) chain.click_and_hold(library_item) chain.move_to_element_with_offset(target, 125, 30) chain.release(None) chain.perform() dialog = ConfirmationPage(self) if confirm: dialog.click_ok() else: dialog.click_cancel()
def attempt_to_close_workspace(self, expectDialog, confirm): """ Close the workspace page. Returns :class:`ProjectsListPage`. """ self('project_menu').click() self('close_button').click() #if you expect the "close without saving?" dialog if expectDialog: dialog = ConfirmationPage(self) if confirm: #close without saving self.browser.execute_script('openmdao.Util.closeWebSockets();') NotifierPage.wait(self) dialog.click_ok() from project import ProjectsListPage return ProjectsListPage.verify(self.browser, self.port) else: #return to the project, intact. dialog.click_cancel() else: #no unsaved changes from project import ProjectsListPage return ProjectsListPage.verify(self.browser, self.port)
def delete_files(self, file_paths, confirm=True): """ Delete all the files in the list `file_paths` """ # need select all the files given in file_paths self('files_tab').click() for filename in file_paths: element = self.find_file(filename) chain = ActionChains(self.browser) #Mac OSX does not use CONTROL key if sys.platform == 'darwin': chain.key_down(Keys.SHIFT).click(element).key_up(Keys.SHIFT).perform() else: chain.key_down(Keys.CONTROL).click(element).key_up(Keys.CONTROL).perform() self('files_tab').click() self('file_menu').click() self('delete_files_button').click() page = ConfirmationPage(self) if confirm: page.click_ok() else: page.click_cancel()
def delete_files(self, file_paths, confirm=True): """ Delete all the files in the list `file_paths` """ # need select all the files given in file_paths self('files_tab').click() for filename in file_paths: element = self.find_file(filename) chain = ActionChains(self.browser) # Mac OSX does not use CONTROL key if sys.platform == 'darwin': chain.key_down(Keys.SHIFT).click(element).key_up(Keys.SHIFT).perform() else: chain.key_down(Keys.CONTROL).click(element).key_up(Keys.CONTROL).perform() self('files_tab').click() self('file_menu').click() self('delete_files_button').click() page = ConfirmationPage(self) if confirm: page.click_ok() else: page.click_cancel()