mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Fixing call to Chrome to generate Archive screenshots.
This commit is contained in:
parent
7efee1fdb2
commit
d85c7721b5
3 changed files with 14 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ calibre
|
|||
cargo
|
||||
catdoc
|
||||
chromium
|
||||
chromium-driver
|
||||
cpufrequtils
|
||||
curl
|
||||
dosfstools
|
||||
|
|
|
|||
|
|
@ -2554,7 +2554,7 @@ def html_screenshot(html: bytes | str) -> bytes:
|
|||
fh.write(html.encode() if isinstance(html, str) else html)
|
||||
fh.flush()
|
||||
|
||||
with webdriver.Chrome(chrome_options=options) as driver:
|
||||
with webdriver.Chrome(options=options) as driver:
|
||||
driver.get(f'file://{fh.name}')
|
||||
driver.set_window_size(1280, 720)
|
||||
screenshot = driver.get_screenshot_as_png()
|
||||
|
|
|
|||
|
|
@ -893,6 +893,18 @@ def test_html_screenshot(singlefile_contents_factory):
|
|||
assert common.html_screenshot(singlefile_contents_factory())
|
||||
|
||||
|
||||
def test_html_screenshot_webdriver_kwargs(singlefile_contents_factory):
|
||||
"""Selenium 4.10 removed the `chrome_options` kwarg; `webdriver.Chrome` must be called with `options`."""
|
||||
with mock.patch('wrolpi.common.webdriver.Chrome') as mock_chrome:
|
||||
driver = mock_chrome.return_value.__enter__.return_value
|
||||
driver.get_screenshot_as_png.return_value = b'PNG'
|
||||
|
||||
assert common.html_screenshot(singlefile_contents_factory()) == b'PNG'
|
||||
|
||||
assert mock_chrome.call_args.kwargs.keys() == {'options'}
|
||||
assert isinstance(mock_chrome.call_args.kwargs['options'], common.webdriver.ChromeOptions)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('color,expected', [
|
||||
('#ffffff', True),
|
||||
('#FFFFFF', True),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue