Position Selenium Firefox driver

36 views Asked by At

I'm trying to start up several Selenium Firefox driver windows side by side. I have successfully changed the size of the window using any of these methods:

    options = selenium.webdriver.FirefoxOptions()
    options.add_argument("--width=200")
    options.add_argument("--height=200")
    driver = selenium.webdriver.Firefox(options=options)
driver = selenium.webdriver.Firefox()
driver.set_window_size(win_sizing.width, win_sizing.height)

However, I cannot manage to change the windows' positions:

# Has no effect on the window position
driver.set_window_position(0, 0)

Are there arguments I can pass to the FirefoxOptions? I have tried with --left=0, --top=0 and --window-position=0,0 (all my guesses - Is there a command line reference somewhere?).

Javascript also has no effect:

driver.execute_script("window.moveTo(0,0);")

How do I change the window position of the Firefox driver?

Ubuntu 23.10, Gnome, Wayland. Python.

I'm starting to think that I have to fallback on X/Wayland/Gnome calls to reposition the window.

edit: This seems to indicate that the driver is not in control of the window position at all :( (Moving the window using the mouse still result in the same x and y coordinates)

>>> driver.set_window_rect(300, 300, 500, 500)
{'x': 26, 'y': 23, 'width': 500, 'height': 500}
0

There are 0 answers