コード例 #1
0
ファイル: export_page.py プロジェクト: egorhm/ggrc-core
  def export_objs_to_csv(self, path_to_export_dir):
    """Click to 'Export Objects' button to export objects, wait for export,
    download as CSV and return path to the downloaded file.
    """
    export_items_before_count = len(self.get_export_items())
    self.export_objs_btn.click()

    def exported_item():
      """Return the export item that was just created."""
      difference = len(self.get_export_items()) - export_items_before_count
      if difference == 1:
        return self.get_export_items()[-1]
      return None
    export_item = test_utils.wait_for(exported_item)
    selenium_utils.set_chrome_download_location(
        self._driver, path_to_export_dir)
    downloads_before = os.listdir(path_to_export_dir)
    export_item.download_csv()

    def path_to_downloaded_file():
      """Path to a file that has appeared."""
      difference = set(os.listdir(path_to_export_dir)) - set(downloads_before)
      if len(difference) == 1:
        filename = list(difference)[0]
        return os.path.join(path_to_export_dir, filename)
      return None
    return test_utils.wait_for(path_to_downloaded_file)
コード例 #2
0
ファイル: export_page.py プロジェクト: zdqf/ggrc-core
    def export_objs_to_csv(self, path_to_export_dir):
        """Click to 'Export Objects' button to export objects, wait for export,
    download as CSV and return path to the downloaded file.
    """
        export_items_before_count = len(self.get_export_items())
        self.export_objs_btn.click()

        def exported_item():
            """Return the export item that was just created."""
            difference = len(
                self.get_export_items()) - export_items_before_count
            if difference == 1:
                return self.get_export_items()[-1]
            return None

        export_item = test_utils.wait_for(exported_item)
        selenium_utils.set_chrome_download_location(self._driver,
                                                    path_to_export_dir)
        downloads_before = os.listdir(path_to_export_dir)
        export_item.download_csv()

        def path_to_downloaded_file():
            """Path to a file that has appeared."""
            difference = set(
                os.listdir(path_to_export_dir)) - set(downloads_before)
            if len(difference) == 1:
                filename = list(difference)[0]
                return os.path.join(path_to_export_dir, filename)
            return None

        return test_utils.wait_for(path_to_downloaded_file)
コード例 #3
0
  def download_obj_to_csv(self, path_to_export_dir):
    """Download as CSV and return path to the downloaded file."""
    export_item = self.get_export_items()[-1]
    selenium_utils.set_chrome_download_location(
        self._driver, path_to_export_dir)
    downloads_before = os.listdir(path_to_export_dir)
    export_item.download_csv()

    def path_to_downloaded_file():
      """Path to a file that has appeared."""
      difference = set(os.listdir(path_to_export_dir)) - set(downloads_before)
      if len(difference) == 1:
        filename = list(difference)[0]
        if not filename.endswith("crdownload"):  # file is not fully downloaded
          return os.path.join(path_to_export_dir, filename)
      return None
    return test_utils.wait_for(path_to_downloaded_file)
コード例 #4
0
    def download_obj_to_csv(self, path_to_export_dir):
        """Download as CSV and return path to the downloaded file."""
        export_item = self.get_export_items()[-1]
        selenium_utils.set_chrome_download_location(self._driver,
                                                    path_to_export_dir)
        downloads_before = os.listdir(path_to_export_dir)
        export_item.download_csv()

        def path_to_downloaded_file():
            """Path to a file that has appeared."""
            difference = set(
                os.listdir(path_to_export_dir)) - set(downloads_before)
            if len(difference) == 1:
                filename = list(difference)[0]
                return os.path.join(path_to_export_dir, filename)
            return None

        return test_utils.wait_for(path_to_downloaded_file)
コード例 #5
0
  def download_export_file(self, path_to_export_dir):
    """Click to 'Export Objects' button to confirm export objects according to
    selected before export format (Google Sheet or CSV) and return path
    to the downloaded file.
    """
    downloads_before = os.listdir(path_to_export_dir)
    selenium_utils.set_chrome_download_location(
        self._driver, path_to_export_dir)
    self.export_objs_btn.click()
    selenium_utils.get_when_invisible(
        self.export_page, locator.Common.SPINNER_CSS)
    selenium_utils.wait_for_js_to_load(self._driver)

    def path_to_downloaded_file():
      """Path to a file that has appeared."""
      difference = set(os.listdir(path_to_export_dir)) - set(downloads_before)
      if len(difference) == 1:
        filename = list(difference)[0]
        return os.path.join(path_to_export_dir, filename)
    return test_utils.wait_for(path_to_downloaded_file)