Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WRAN-1239-find-differences-file-graphs #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 72 additions & 1 deletion qancode/clickpaths.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
26 changes: 18 additions & 8 deletions qancode/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
OpenUCSCGenomeBrowserMM10fromExperiment,
OpenUCSCGenomeBrowserMM10MinimalfromExperiment,
OpenUCSCGenomeBrowserMM9fromExperiment,
ClickSearchResultItem)
ClickSearchResultItem,
ClickSearchResultItemAndMakeExperimentPagesLookTheSame,
MakeExperimentPagesLookTheSameByClickingFileTab,
MakeExperimentPagesLookTheSameByHidingGraph
)

# Default browsers.
BROWSERS = ['Chrome',
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions qancode/pageobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 0 additions & 11 deletions qancode/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions qancode/worker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import time
import sys
import traceback

from .clickpaths import (DownloadBEDFileFromModal,
DownloadBEDFileFromTable,
Expand Down Expand Up @@ -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()
Expand Down