Пример #1
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)
Пример #2
0
    def add_library_item_to_dataflow(self, item_name, instance_name, check=True, offset=None, prefix=None):
        """ Add component `item_name`, with name `instance_name`. """
        library_item = self.get_library_item(item_name)

        target = WebDriverWait(self.browser, TMO).until(
            lambda browser: browser.find_element_by_xpath("//*[@id='-dataflow']")
        )

        offset = offset or (90, 90)
        chain = ActionChains(self.browser)
        if False:
            chain.drag_and_drop(library_item, target)
        else:
            chain.click_and_hold(library_item)
            chain.move_to_element_with_offset(target, offset[0], offset[1])
            chain.release(None)
        chain.perform()

        page = ValuePrompt(self.browser, self.port)
        page.set_value(instance_name)
        # Check that the prompt is gone so we can distinguish a prompt problem
        # from a dataflow update problem.
        time.sleep(0.25)
        self.browser.implicitly_wait(1)  # We don't expect to find anything.
        try:
            eq(len(self.browser.find_elements(*page("prompt")._locator)), 0)
        finally:
            self.browser.implicitly_wait(TMO)

        retval = None
        if check:  # Check that it's been added.
            retval = WebDriverWait(self.browser, TMO).until(
                lambda browser: self.get_dataflow_figure(instance_name, prefix)
            )
        return retval
Пример #3
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)
Пример #4
0
    def new_file(self, filename, code):
        """ Make a new file `filename` with contents `code`. """
        self('file_menu').click()
        self('newfile_button').click()

        page = ValuePrompt(self.browser, self.port)
        page.set_value(filename)

        self.edit_file(filename)

        # Switch to editor textarea
        code_input_element = WebDriverWait(self.browser, TMO).until(
            lambda browser: browser.find_element_by_css_selector('textarea'))
# FIXME: absolute delay for editor to get ready.
#        Problem is Firefox sometimes sends arrow key to scrollbar.
#        Sadly this didn't completely fix the issue.
        time.sleep(1)

        # 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)
        # Control-S to save.
        if sys.platform == 'darwin':
            code_input_element.send_keys(Keys.COMMAND + 's')
        else:
            code_input_element.send_keys(Keys.CONTROL + 's')
# FIXME: absolute delay for save to complete.
        time.sleep(2)

        # Back to main window.
        self.browser.switch_to_default_content()
Пример #5
0
    def add_library_item_to_dataflow(self, item_name, instance_name):
        """ Add component `item_name`, with name `instance_name`. """
        #xpath = "//div[(@id='palette')]//div[(@path='%s')]" % item_name
        xpath = "//table[(@id='objtypetable')]//td[(@modpath='%s')]" % item_name
        library_item = WebDriverWait(
            self.browser,
            TMO).until(lambda browser: browser.find_element_by_xpath(xpath))
        WebDriverWait(self.browser,
                      TMO).until(lambda browser: library_item.is_displayed())
        # FIXME: absolute delay to wait for 'slide' to complete.
        time.sleep(1)

        target = WebDriverWait(
            self.browser,
            TMO).until(lambda browser: browser.find_element_by_xpath(
                "//*[@id='-dataflow']"))

        chain = ActionChains(self.browser)
        if False:
            chain = chain.drag_and_drop(library_item, target)
        else:
            chain = chain.click_and_hold(library_item)
            chain = chain.move_to_element_with_offset(target, 100, 100)
            chain = chain.release(None)
        chain.perform()

        page = ValuePrompt(self.browser, self.port)
        page.set_value(instance_name)
        # Check that the prompt is gone so we can distinguish a prompt problem
        # from a dataflow update problem.
        time.sleep(0.25)
        eq(len(self.browser.find_elements(*page('prompt')._locator)), 0)
        WebDriverWait(self.browser,
                      TMO).until(lambda browser: instance_name in self.
                                 get_dataflow_component_names())
Пример #6
0
 def rename_file(self, old, new):
     """ Rename `old` to `new`. """
     self('files_tab').click()
     element = self.find_file(old)
     chain = ActionChains(self.browser)
     chain.context_click(element).perform()
     self('file_rename').click()
     prompt = ValuePrompt(self.browser, self.port)
     prompt.set_value(new)
Пример #7
0
 def rename_file(self, old, new):
     """ Rename `old` to `new`. """
     self('files_tab').click()
     element = self.find_file(old)
     chain = ActionChains(self.browser)
     chain.context_click(element).perform()
     self('file_rename').click()
     prompt = ValuePrompt(self.browser, self.port)
     prompt.set_value(new)
Пример #8
0
    def add_library_item_to_dataflow(self,
                                     item_name,
                                     instance_name,
                                     check=True,
                                     offset=None,
                                     prefix=None):
        """ Add component `item_name`, with name `instance_name`. """
        library_item = self.get_library_item(item_name)

        target = WebDriverWait(
            self.browser,
            TMO).until(lambda browser: browser.find_element_by_xpath(
                "//*[@id='-dataflow']"))

        offset = offset or (90, 90)
        chain = ActionChains(self.browser)
        if False:
            chain.drag_and_drop(library_item, target)
        else:
            chain.click_and_hold(library_item)
            chain.move_to_element_with_offset(target, offset[0], offset[1])
            chain.release(None)
        chain.perform()

        page = ValuePrompt(self.browser, self.port)
        page.set_value(instance_name)
        # Check that the prompt is gone so we can distinguish a prompt problem
        # from a dataflow update problem.
        time.sleep(0.25)
        self.browser.implicitly_wait(1)  # We don't expect to find anything.
        try:
            eq(len(self.browser.find_elements(*page('prompt')._locator)), 0)
        finally:
            self.browser.implicitly_wait(TMO)

        retval = None
        if check:  # Check that it's been added.
            retval = WebDriverWait(
                self.browser,
                TMO).until(lambda browser: self.get_dataflow_figure(
                    instance_name, prefix))
        return retval
Пример #9
0
 def set_source_expression(self, expr):
     """ Set the source to expression. """
     self('expression_button').click()
     dialog = ValuePrompt(self.browser, self.port)
     dialog.set_value(expr)