Designed to work with custom ApacheSuperset charts.
Allows you to get the generated pdf(A4 landscape format) from a page with expanded content.
getPdf();
Returns: binary file object.
Allows you to get a styled xlsx file from a table.
saveTable2XLSX($(".pvtTable")[0], "Table title");
Returns: binary file object.
- PDF:
- XLSX
Module contains decorator exec_js_wrapper that makes it easier to work with selenium by returning a prepared and configured webdriver.
- callable, - decorated function.
- default_driver:AnyDriver = Firefox, - target webdriver for work.
- driver_opt:Dict[str, Any] = {}, - addition options for webdriver.
- headless:bool = True, - separated headless webdriver option.
- window_size:Tuple[int, int] = (1850, 1132) - separated window_size webdriver option.
- url: str - url of target page.
- wait_until: Optional[ExceptedCondition] = None - optional ExceptedCondition callable object from selenium.webdriver.support when we need wait some event before processing.
- wait_timeout:int = 600 - timeout for condition waiting.
- *args
- **kwargs
# Using default decorator params
@exec_js_wrapper
def bpdf_from_url(driver:'WebDriver', *args, **kwargs) -> bytes:
"""Returns binary pdf of page."""
script = 'return getPdf();'
result = base64.b64decode(
driver.execute_script(script)
)
return result
The function to be decorated must have the driver as input parameters to work directly with selenium.webdriver.
url = "example.com"
wait_condition = selenium_js_executor.expected_conditions.invisibility_of_element_located(
(selenium_js_executor.By.XPATH, '//*[@id="load"]')
)
timeout = 600
pdf_data_1 = bpdf_from_url(url, wait_condition, timeout)
open('result_1.pdf', 'wb').write(pdf_data_1)