Skip to content Skip to sidebar Skip to footer

How To Set Window Position Of Firefox Browser Through Selenium Using Firefoxprofile Or Firefoxoptions

I need to change the position of the Firefox window by creating the driver with: driver = webdriver.Firefox() I know it's possible to change the window position after the driver w

Solution 1:

You saw it right.

set_window_position()

set_window_position() sets the x,y position of the current window.

  • Implementation:

      set_window_position(x, y, windowHandle='current')
      Sets the x,y position of the current window. (window.moveTo)
    
      Arguments :
          x: the x-coordinate in pixels toset the window position
          y: the y-coordinate in pixels toset the window position
      Usage :
          driver.set_window_position(0,0)
    
  • Definition:

    defset_window_position(self, x, y, windowHandle='current'):
          if self.w3c:
              if windowHandle != 'current':
              warnings.warn("Only 'current' window is supported for W3C compatibile browsers.")
              return self.set_window_rect(x=int(x), y=int(y))
          else:
              self.execute(Command.SET_WINDOW_POSITION,
                   {
                       'x': int(x),
                       'y': int(y),
                       'windowHandle': windowHandle
                   })
    

So to summarize, window_position is coupled to the window handle pertaining to the browser and can be handled by webdriver instance only.

This functionality can't be handled either through:

Post a Comment for "How To Set Window Position Of Firefox Browser Through Selenium Using Firefoxprofile Or Firefoxoptions"