From 4bf9b30b427018616d5ce9f69eade3516e701cd1 Mon Sep 17 00:00:00 2001 From: Paul Sud Date: Fri, 19 Jul 2019 11:33:35 -0700 Subject: [PATCH] update find_differences and clickpaths for checking file graphs --- qancode/clickpaths.py | 73 +++++++++++++++++++++++++++++++++++++++++- qancode/defaults.py | 26 ++++++++++----- qancode/pageobjects.py | 2 ++ qancode/tasks.py | 11 ------- qancode/worker.py | 4 +++ 5 files changed, 96 insertions(+), 20 deletions(-) diff --git a/qancode/clickpaths.py b/qancode/clickpaths.py index 04cb92da..5a39c132 100644 --- a/qancode/clickpaths.py +++ b/qancode/clickpaths.py @@ -502,4 +502,75 @@ def perform_action(self): self.driver.execute_script('arguments[0].scrollIntoView(true)', item_link) self.driver.execute_script('arguments[0].click()', item_link) except: - pass \ No newline at end of file + pass + + +class ClickSearchResultItemAndMakeExperimentPagesLookTheSame: + """ + Clicks the first item on a page of search results. + """ + + def __init__(self, driver): + self.driver = driver + self.perform_action() + + def perform_action(self): + try: + item_link = self.driver.find_element_by_xpath(SearchPageList.search_result_item) + self.driver.execute_script('arguments[0].scrollIntoView(true)', item_link) + self.driver.execute_script('arguments[0].click()', item_link) + self.driver.wait.until( + EC.element_to_be_clickable((By.XPATH, ExperimentPage.file_graph_tab_xpath)) + ).click() + self.driver.wait.until( + EC.element_to_be_clickable((By.XPATH, ExperimentPage.sort_by_accession_xpath)) + ).click() + except: + pass + + +class MakeExperimentPagesLookTheSameByClickingFileTab: + """ + Makes two experiment pages look the same by clicking on the file tab and sorting by accession. + """ + + def __init__(self, driver): + self.driver = driver + self.perform_action() + + def perform_action(self): + try: + self.driver.wait.until( + EC.element_to_be_clickable((By.XPATH, ExperimentPage.file_graph_tab_xpath)) + ).click() + self.driver.wait.until( + EC.element_to_be_clickable((By.XPATH, ExperimentPage.sort_by_accession_xpath)) + ).click() + except: + pass + + +class MakeExperimentPagesLookTheSameByHidingGraph: + """ + Makes two experiment pages look the same by making hiding the file graph. The "include + deprecated files" button is also checked in order to get the file status bar to appear. + """ + def __init__(self, driver): + self.driver = driver + self.perform_action() + + def perform_action(self): + try: + file_graph = self.driver.wait_long.until( + EC.presence_of_element_located((By.ID, ExperimentPage.file_graph_id)) + ) + self.driver.execute_script("arguments[0].style.visibility='hidden'", file_graph) + checkbox = self.driver.wait.until( + EC.element_to_be_clickable( + (By.NAME, ExperimentPage.incl_deprecated_files_button_name) + ) + ) + if not checkbox.is_selected(): + checkbox.click() + except: + pass diff --git a/qancode/defaults.py b/qancode/defaults.py index 566984ed..b9969681 100644 --- a/qancode/defaults.py +++ b/qancode/defaults.py @@ -28,7 +28,11 @@ OpenUCSCGenomeBrowserMM10fromExperiment, OpenUCSCGenomeBrowserMM10MinimalfromExperiment, OpenUCSCGenomeBrowserMM9fromExperiment, - ClickSearchResultItem) + ClickSearchResultItem, + ClickSearchResultItemAndMakeExperimentPagesLookTheSame, + MakeExperimentPagesLookTheSameByClickingFileTab, + MakeExperimentPagesLookTheSameByHidingGraph + ) # Default browsers. BROWSERS = ['Chrome', @@ -148,13 +152,19 @@ def _init_default_actions(self): ('/biosamples/ENCBS682JHS/', None), ('/cart-manager/', None), ('/cart-view/', None), - ('/experiments/ENCSR000AEH/', None), - ('/experiments/ENCSR178NTX/', None), - ('/experiments/ENCSR255XZG/', None), - ('/experiments/ENCSR651NGR/', None), - ('/experiments/ENCSR714GXC/', None), - ('/search/?type=Experiment&status=in+progress&audit.INTERNAL_ACTION=%2A&sort=date_created', ClickSearchResultItem), - ('/search/?type=Experiment&status=submitted&sort=date_submitted', ClickSearchResultItem), + ('/experiments/ENCSR000AEH/', MakeExperimentPagesLookTheSameByClickingFileTab), + ('/experiments/ENCSR178NTX/', MakeExperimentPagesLookTheSameByClickingFileTab), + ('/experiments/ENCSR255XZG/', MakeExperimentPagesLookTheSameByClickingFileTab), + ('/experiments/ENCSR651NGR/', MakeExperimentPagesLookTheSameByHidingGraph), + ('/experiments/ENCSR714GXC/', MakeExperimentPagesLookTheSameByHidingGraph), + ( + '/search/?type=Experiment&status=in+progress&audit.INTERNAL_ACTION=%2A&sort=date_created', + ClickSearchResultItemAndMakeExperimentPagesLookTheSame + ), + ( + '/search/?type=Experiment&status=submitted&sort=date_submitted', + ClickSearchResultItemAndMakeExperimentPagesLookTheSame + ), ('/search/?type=File&status=in+progress&derived_from=%2A&quality_metrics=%2A&sort=date_created', ClickSearchResultItem), ('/files/ENCFF703RFN/', None), ('/files/ENCFF933XVP/', None), diff --git a/qancode/pageobjects.py b/qancode/pageobjects.py index 445b739c..436a5915 100644 --- a/qancode/pageobjects.py +++ b/qancode/pageobjects.py @@ -75,6 +75,8 @@ class ExperimentPage: information_button_relative_xpath = '..//td[1]//span//button//i' file_graph_tab_xpath = '//div[@class="tab-nav"]//li[2]' assembly_selector_xpath = '/html/body/div[@id="slot-application"]/div[@id="application"]/div[@id="layout"]/div/div[@id="content"]/div/div[@class="done"]/div/div[@class="file-gallery-controls"]//div[@class="file-gallery-controls__assembly-selector"]/select[@class="form-control--select"]' + file_graph_id = 'pipeline-graph' + incl_deprecated_files_button_name = 'filterIncArchive' class FilePage: diff --git a/qancode/tasks.py b/qancode/tasks.py index bfec3292..b3c8f5aa 100644 --- a/qancode/tasks.py +++ b/qancode/tasks.py @@ -547,20 +547,9 @@ def take_screenshot(self): self.stitch_image(image_path) return image_path - def make_experiment_pages_look_the_same(self): - self.driver.wait.until(EC.element_to_be_clickable( - (By.XPATH, ExperimentPage.file_graph_tab_xpath))).click() - self.driver.wait.until(EC.element_to_be_clickable( - (By.XPATH, ExperimentPage.sort_by_accession_xpath))).click() - def get_data(self): self._try_load_item_type() self._try_perform_click_path() - if 'experiment' in self.driver.current_url.lower(): - try: - self.make_experiment_pages_look_the_same() - except: - pass try: self._expand_document_details() except: diff --git a/qancode/worker.py b/qancode/worker.py index b69a5538..dcfd0cb6 100644 --- a/qancode/worker.py +++ b/qancode/worker.py @@ -1,4 +1,6 @@ import time +import sys +import traceback from .clickpaths import (DownloadBEDFileFromModal, DownloadBEDFileFromTable, @@ -76,6 +78,8 @@ def run_task(self): except Exception as e: print('{}Exception caught: {}{}'.format( bcolors.FAIL, e, bcolors.ENDC)) + # Print full traceback + traceback.print_tb(sys.exc_info()[2]) finally: try: self.driver.quit()