admin管理员组文章数量:1252714
I am using Selenium + Chromium headless for automated testing, and the execution environment has been encapsulated into a Docker image based on Debian. Through screenshots taken during the execution, I noticed that the page is being scaled down. I set the resolution to 1920×1080, and while the page meets this resolution, the elements appear to be shrunk, with large white margins on both sides. Here is an example of a normal webpage: And here is the screenshot taken by Selenium:
My chromium variables is :
--headless
--window-size= 1920,1080
--force-device-scale-factor=1
--disable-gpu
--no-sandbox
--hide-scrollbars
--disable-dev-shm-usage
--remote-allow-origins=*
My docker file likes:
FROM debian:bookworm-slim
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
chromium \
libglib2.0-0 \
libnss3-dev \
libxcb1 \
locales \
openjdk-17-jre \
fontconfig \
fonts-ipafont-gothic \
fonts-wqy-zenhei \
fonts-thai-tlwg \
fonts-kacst \
fonts-symbola \
fonts-noto \
fonts-freefont-ttf
Please tell me what I should do next. Thank you.
I am using Selenium + Chromium headless for automated testing, and the execution environment has been encapsulated into a Docker image based on Debian. Through screenshots taken during the execution, I noticed that the page is being scaled down. I set the resolution to 1920×1080, and while the page meets this resolution, the elements appear to be shrunk, with large white margins on both sides. Here is an example of a normal webpage: And here is the screenshot taken by Selenium:
My chromium variables is :
--headless
--window-size= 1920,1080
--force-device-scale-factor=1
--disable-gpu
--no-sandbox
--hide-scrollbars
--disable-dev-shm-usage
--remote-allow-origins=*
My docker file likes:
FROM debian:bookworm-slim
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
chromium \
libglib2.0-0 \
libnss3-dev \
libxcb1 \
locales \
openjdk-17-jre \
fontconfig \
fonts-ipafont-gothic \
fonts-wqy-zenhei \
fonts-thai-tlwg \
fonts-kacst \
fonts-symbola \
fonts-noto \
fonts-freefont-ttf
Please tell me what I should do next. Thank you.
Share Improve this question asked Feb 14 at 5:59 linxiao yulinxiao yu 132 bronze badges 01 Answer
Reset to default 0Try this to set resolution
driver.set_window_size(1920, 1080)
driver.save_screenshot("file_name.png")
本文标签:
版权声明:本文标题:google chrome - The Chromium headless page is scaled, and the resolution is not as expected - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740310906a2259388.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论