Last active
October 5, 2018 12:08
-
-
Save alexpreynolds/8bc191354d824545b281086e4e8870ac to your computer and use it in GitHub Desktop.
Selenium Python binding test (Ubuntu 16)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from selenium import webdriver | |
| from selenium.webdriver.support.ui import WebDriverWait | |
| from selenium.webdriver.support import expected_conditions as EC | |
| from selenium.webdriver.common.by import By | |
| from selenium.common.exceptions import TimeoutException | |
| import sys | |
| import time | |
| chrome_options = webdriver.ChromeOptions() | |
| chrome_options.add_argument('--headless') | |
| chrome_options.add_argument('--no-sandbox') | |
| chrome_options.add_argument('--disable-dev-shm-usage') | |
| chrome_options.add_argument('--enable-webgl-image-chromium') | |
| chrome_options.add_argument('--disable-application-cache') | |
| driver = webdriver.Chrome(executable_path="/usr/bin/chromedriver",chrome_options=chrome_options) | |
| driver.set_window_size(950,1100) | |
| driver.get("http://explorer.altius.org/app/?config=SUFTOi4wT5S79NgyLKPTcg&chr=chr3&start=181500000&stop=181800000") | |
| delay = 3 # seconds | |
| try: | |
| hg = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.CLASS_NAME, 'higlass'))) | |
| time.sleep(1) | |
| svg = driver.execute_async_script(""" | |
| var done = arguments[0]; | |
| window.setTimeout(function(){ done(window.higlassApi.exportAsSvg()); }, 0); | |
| """) | |
| sys.stdout.write(svg) | |
| except TimeoutException: | |
| sys.stderr.write("Error: Loading took too much time!") | |
| driver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment