|
25 | 25 | from selenium.webdriver.remote.webelement import WebElement |
26 | 26 | from selenium.webdriver.support.wait import WebDriverWait, TimeoutException, NoSuchElementException |
27 | 27 | from selenium.webdriver.support import expected_conditions as EC |
| 28 | +from selenium.webdriver.common.print_page_options import PrintOptions |
28 | 29 |
|
29 | 30 | from . import config, cv2find, compat |
30 | 31 | from .browsers import BROWSER_CONFIGS, Browser, PageLoadStrategy |
@@ -266,7 +267,7 @@ def check_driver(): |
266 | 267 | def _get_parameters_to_driver(self): |
267 | 268 | if self.browser == Browser.UNDETECTED_CHROME: |
268 | 269 | return {"driver_executable_path": self.driver_path, "options": self.options, |
269 | | - "desired_capabilities": self.capabilities} |
| 270 | + "desired_capabilities": self.capabilities, "headless": True} |
270 | 271 | if compat.version_selenium_is_larger_than_four(): |
271 | 272 | return {"options": self.options, "service": self._get_service()} |
272 | 273 |
|
@@ -1137,7 +1138,13 @@ def print_pdf(self, path=None, print_options=None): |
1137 | 1138 | 'marginTop': 0, |
1138 | 1139 | 'marginBottom': 0 |
1139 | 1140 | } |
1140 | | - data = self._webdriver_command("print", print_options) |
| 1141 | + print_options = PrintOptions() |
| 1142 | + print_options.page_ranges = ['1-2'] |
| 1143 | + print_options.margin_top = 0 |
| 1144 | + print_options.margin_bottom = 0 |
| 1145 | + print_options.background = True |
| 1146 | + print_options.orientation = 'landscape' |
| 1147 | + data = self._driver.print_page(print_options) |
1141 | 1148 | bytes_file = base64.b64decode(data) |
1142 | 1149 | if not path: |
1143 | 1150 | path = default_path |
|
0 commit comments