0

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?

4
  • I can set custom window size with python: Code trials please? Commented Apr 8, 2022 at 11:20
  • driver.set_window_size(1366,768) and options.add_argument("--window-size=1366,768") tried both Commented Apr 8, 2022 at 11:28
  • Why do you need to change screen resolution? Is not enough changing driver window size? Commented Apr 8, 2022 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. Commented Apr 8, 2022 at 11:48

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Ok no this doesn't work, but maybe a step in the right direction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.