Example #1
0
    def __init__(self, browser, port):
        super(WorkspacePage, self).__init__(browser, port)

        self.locators = {}
        self.locators["objects"] = (By.XPATH,
                                    "//div[@id='otree_pane']//li[@path]")
        self.locators["files"] = (
            By.XPATH, "//div[@id='ftree_pane']//a[@class='file ui-draggable']")

        # Wait for bulk of page to load.
        WebDriverWait(
            self.browser,
            TMO).until(lambda browser: len(self.get_dataflow_figures()) > 0)

        # Now wait for all WebSockets open.
        browser.execute_script('openmdao.Util.webSocketsReady(2);')
        expected = 'WebSockets open'
        try:
            msg = NotifierPage.wait(self)
        except TimeoutException:  # Typically no exception text is provided.
            raise TimeoutException('Timed-out waiting for web sockets')
        while msg != expected:
            # During 'automatic' reloads we can see 'WebSockets closed'
            logging.warning('Acknowledged %r while waiting for %r', msg,
                            expected)
            time.sleep(1)
            try:
                msg = NotifierPage.wait(self)
            except TimeoutException:
                raise TimeoutException('Timed-out waiting for web sockets')
Example #2
0
 def __init__(self, browser, port, locator, version=Version.OLD):
     super(ComponentPage, self).__init__(browser, port, locator)
     # It takes a while for the full load to complete.
     NotifierPage.wait(self)
     self.version = version
     self._sort_order = {"inputs": 0, "outputs": 0}
     self._column_picker = None
    def __init__(self, browser, port):
        super(WorkspacePage, self).__init__(browser, port)

        self.locators = {}
        self.locators["objects"] = (By.XPATH, "//div[@id='otree_pane']//li[@path]")
        self.locators["files"] = (By.XPATH, "//div[@id='ftree_pane']//a[@class='file ui-draggable']")

        # Wait for bulk of page to load.
        WebDriverWait(self.browser, TMO).until(
            lambda browser: len(self.get_dataflow_figures()) > 0)

        # Now wait for all WebSockets open.
        browser.execute_script('openmdao.Util.webSocketsReady(2);')
        
        try:  # We may get 2 notifiers: sockets open and sockets closed.
            msg = NotifierPage.wait(self, base_id='ws_open')
        except Exception as exc:
            if 'Element is not clickable' in str(exc):
                msg2 = NotifierPage.wait(self, base_id='ws_closed')
                msg = NotifierPage.wait(self, base_id='ws_open')
            else:
                raise
        else:
            try:
                msg2 = NotifierPage.wait(self, base_id='ws_closed')
            except TimeoutException:
                pass # ws closed dialog may not exist
Example #4
0
 def commit_project(self, comment='no comment'):
     """ Commit current project. """
     self('project_menu').click()
     self('commit_button').click()
     page = ValuePrompt(self.browser, self.port)
     page.set_value(comment)
     NotifierPage.wait(self)
Example #5
0
 def __init__(self, browser, port, locator, version=Version.OLD):
     super(ComponentPage, self).__init__(browser, port, locator)
     # It takes a while for the full load to complete.
     NotifierPage.wait(self)
     self.version = version
     self._sort_order = {"inputs": 0, "outputs": 0}
     self._column_picker = None
Example #6
0
    def __init__(self, browser, port):
        super(WorkspacePage, self).__init__(browser, port)

        self.locators = {}
        self.locators["objects"] = (By.XPATH, "//div[@id='otree_pane']//li[@path]")
        self.locators["files"] = (By.XPATH, "//div[@id='ftree_pane']//a[@class='file ui-draggable']")

        # Wait for bulk of page to load.
        WebDriverWait(self.browser, TMO).until(lambda browser: len(self.get_dataflow_figures()) > 0)

        # Now wait for all WebSockets open.
        browser.execute_script("openmdao.Util.webSocketsReady(2);")
        expected = "WebSockets open"
        try:
            msg = NotifierPage.wait(self)
        except TimeoutException:  # Typically no exception text is provided.
            raise TimeoutException("Timed-out waiting for web sockets")
        while msg != expected:
            # During 'automatic' reloads we can see 'WebSockets closed'
            logging.warning("Acknowledged %r while waiting for %r", msg, expected)
            time.sleep(1)
            try:
                msg = NotifierPage.wait(self)
            except TimeoutException:
                raise TimeoutException("Timed-out waiting for web sockets")
Example #7
0
 def commit_project(self, comment="no comment"):
     """ Commit current project. """
     self("project_menu").click()
     self("commit_button").click()
     page = ValuePrompt(self.browser, self.port)
     page.set_value(comment)
     NotifierPage.wait(self)
Example #8
0
 def save_document(self, overwrite=False, check=True, cancel=False):
     #use 'save' button to save code
     self('editor_save_button').click()
     if overwrite:
         self('editor_overwrite_button').click()
     elif cancel:
         self('editor_cancel_button').click()
     if check:
         NotifierPage.wait(self)
 def save_document(self, overwrite=False, check=True, cancel=False):
     #use 'save' button to save code
     self('editor_save_button').click()
     if overwrite:
         self('editor_overwrite_button').click()
     elif cancel:
         self('editor_cancel_button').click()
     if check:
         NotifierPage.wait(self)
Example #10
0
    def close_workspace(self, commit=False):
        """ Close the workspace page. Returns :class:`ProjectsListPage`. """
        if commit:
            self.commit_project()
        self.browser.execute_script('openmdao.Util.closeWebSockets();')
        NotifierPage.wait(self)
        self('project_menu').click()
        self('close_button').click()

        from project import ProjectsListPage
        return ProjectsListPage.verify(self.browser, self.port)
    def close_workspace(self, commit=False):
        """ Close the workspace page. Returns :class:`ProjectsListPage`. """
        if commit:
            self.commit_project()
        self.browser.execute_script('openmdao.Util.closeWebSockets();')
        NotifierPage.wait(self, base_id='ws_closed')
        self('project_menu').click()
        self('close_button').click()

        from project import ProjectsListPage
        return ProjectsListPage.verify(self.browser, self.port)
Example #12
0
    def __init__(self, browser, port):
        super(WorkspacePage, self).__init__(browser, port)

        self.locators = {}
        self.locators["objects"] = \
            (By.XPATH, "//div[@id='otree_pane']//li[@path]")
        self.locators["files"] = \
            (By.XPATH, "//div[@id='ftree_pane']//a[@class='file ui-draggable']")

        # Wait for bulk of page to load.
        WebDriverWait(self.browser, TMO).until(
            lambda browser: len(self.get_dataflow_figures()) > 0)

        # Now wait for all WebSockets open.
        browser.execute_script('openmdao.project.webSocketsReady(2);')

        try:  # We may get 2 notifiers: sockets open and sockets closed.
            NotifierPage.wait(self, base_id='ws_open')
        except Exception as exc:
            if 'Element is not clickable' in str(exc):
                NotifierPage.wait(self, base_id='ws_closed')
                NotifierPage.wait(self, base_id='ws_open')
            else:
                raise
        else:
            self.browser.implicitly_wait(1)
            try:
                NotifierPage.wait(self, timeout=1, base_id='ws_closed',
                                  retries=0)
            except TimeoutException:
                pass  # ws closed dialog may not exist
            finally:
                self.browser.implicitly_wait(TMO)
Example #13
0
    def __init__(self, browser, port):
        super(WorkspacePage, self).__init__(browser, port)

        self.locators = {}
        self.locators["objects"] = (By.XPATH, "//div[@id='otree']//li[@path]")

        # Wait for bulk of page to load.
        WebDriverWait(
            self.browser, 2 *
            TMO).until(lambda browser: len(self.get_dataflow_figures()) > 0)
        # Now wait for WebSockets.
        # FIXME: absolute delay before polling sockets.
        time.sleep(2)
        browser.execute_script('openmdao.Util.webSocketsReady(2);')
        NotifierPage.wait(browser, port)
Example #14
0
    def new_file(self, filename, code, check=True):
        """ Make a new file `filename` with contents `code`. """
        page = self.new_file_dialog()
        page.set_value(filename)

        NotifierPage.wait(self)  # Wait for creation to complete.

        # Switch to editor textarea
        code_input_element = self.get_text_area()

        # Go to the bottom of the code editor window
        for i in range(4):
            code_input_element.send_keys(Keys.ARROW_DOWN)
        # Type in the code.
        code_input_element.send_keys(code)

        self.save_document(check=check)
    def new_file(self, filename, code, check=True):
        """ Make a new file `filename` with contents `code`. """
        page = self.new_file_dialog()
        page.set_value(filename)

        NotifierPage.wait(self)  # Wait for creation to complete.

        # Switch to editor textarea
        code_input_element = self.get_text_area()

        # Go to the bottom of the code editor window
        for i in range(4):
            code_input_element.send_keys(Keys.ARROW_DOWN)
        # Type in the code.
        code_input_element.send_keys(code)
        
        self.save_document(check=check)
Example #16
0
    def close_workspace(self):
        """ Close the workspace page. Returns :class:`ProjectsListPage`. """
        self.browser.execute_script('openmdao.Util.closeWebSockets();')
        NotifierPage.wait(self.browser, self.port)
        self('project_menu').click()

        # Sometimes chromedriver hangs here, so we click in separate thread.
        # It's a known issue on the chromedriver site.
        closer = threading.Thread(target=self._closer)
        closer.daemon = True
        closer.start()
        closer.join(60)
        if closer.is_alive():
            abort(True)
            raise SkipTest("Can't close workspace, driver hung :-(")

        from project import ProjectsListPage
        return ProjectsListPage.verify(self.browser, self.port)
Example #17
0
    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 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)
Example #19
0
 def run(self, timeout=TMO):
     """ Run current component. """
     self('project_menu').click()
     self('run_button').click()
     NotifierPage.wait(self, timeout)
Example #20
0
 def new_file(self, filename):
     """ Make a new empty file `filename`. """
     page = self.new_file_dialog()
     page.set_value(filename)
     NotifierPage.wait(self)  # Wait for creation to complete.
Example #21
0
 def do_command(self, cmd, timeout=TMO, ack=True):
     """ Execute a command. """
     self.command = cmd
     self("submit").click()
     if ack:
         NotifierPage.wait(self, timeout, base_id="command")
Example #22
0
 def run(self, timeout=TMO):
     """ Run current component. """
     self("project_menu").click()
     self("run_button").click()
     NotifierPage.wait(self, timeout)
Example #23
0
 def do_command(self, cmd, timeout=TMO):
     """ Execute a command. """
     self.command = cmd
     self('submit').click()
     NotifierPage.wait(self.browser, self.port, timeout)
Example #24
0
 def __init__(self, browser, port, locator):
     super(ComponentPage, self).__init__(browser, port, locator)
     # It takes a while for the full load to complete.
     NotifierPage.wait(self)
Example #25
0
 def __init__(self, browser, port, locator): 
     super(ComponentPage, self).__init__(browser, port, locator) 
     # It takes a while for the full load to complete. 
     NotifierPage.wait(self)
Example #26
0
 def save_project(self):
     """ Save current project. """
     self('project_menu').click()
     self('save_button').click()
     NotifierPage.wait(self.browser, self.port)
Example #27
0
 def new_file(self, filename):
     """ Make a new empty file `filename`. """
     page = self.new_file_dialog()
     page.set_value(filename)
     NotifierPage.wait(self)  # Wait for creation to complete.
Example #28
0
 def do_command(self, cmd, timeout=TMO, ack=True):
     """ Execute a command. """
     self.command = cmd
     self('submit').click()
     if ack:
         NotifierPage.wait(self, timeout, base_id='command')