I can set custom window size with python, but can detect my desktop resolution anyway. I need to change screenResolution = 1920,1080 availableScreenResolution = 1920,1032 with selenium chrome. Is it possible?
Asked
Active
Viewed 410 times
0
-
_I can set custom window size with python_: Code trials please? – undetected Selenium Apr 08 '22 at 11:20
-
`driver.set_window_size(1366,768)` and `options.add_argument("--window-size=1366,768")` tried both – Monjurul Majid Apr 08 '22 at 11:28
-
Why do you need to change screen resolution? Is not enough changing driver window size? – Wonka Apr 08 '22 at 11:39
-
In order to manipulate the browser fingerprint, I need to change screen resolution, changing window size doesn't help in this case. – Monjurul Majid Apr 08 '22 at 11:48
1 Answers
0
Screen resolution is retrieved from the screen object. If you enter the console and type screen you will see the values and properties.
You can execute javascript to change the obejct's values like this
driver.execute_script(js)
Object.defineProperty(screen, "availHeight", {
value: 200,
})
The problem is this object refreshes with every change of location so you'd probably need an extension that executes this every time the browser makes a request
EDIT you can use event handlers to trigger it every time you navigate trigger python events driven by selenium controlled browser

dasfacc
- 148
- 2
- 8