3

I'm using selenium webdriver, there is an only maximize_window() method, how can I make the window "iconized" under windows and Linux ?

from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://www.google.com')

# they only have maximize but no minimize ...
browser.maximize_windows()

edit: found a snippet for windows here

import win32gui

toplist = []
winlist = []
def enum_callback(hwnd, results):
    winlist.append((hwnd, win32gui.GetWindowText(hwnd)))

win32gui.EnumWindows(enum_callback, toplist)
firefox = [(hwnd, title) for hwnd, title in winlist if 'firefox' in title.lower()]
# just grab the first window that matches
firefox = firefox[0]
# use the window handle to set focus
win32gui.SetForegroundWindow(firefox[0])

# To minimize the window, the following line:
import win32con
win32gui.ShowWindow(firefox[0], win32con.SW_MINIMIZE)

since I get get the window hwid from browser object:

browser.current_window_handle

I know I can probably do this in windows. but under linux, is there a universal way of doing it ? or it's related to what desktop managers i'm using ?

currently, I have used it with centos 6.4, kde desktop, and fedora20 lxde desktop

iamsankalp89
  • 4,607
  • 2
  • 15
  • 36
Shuman
  • 3,914
  • 8
  • 42
  • 65
  • On linux, in my opinion, this would be very-much dependent on the Window manager. Having said that, you might be able to find Linux software written that iconises in both KDE and GNOME, presumably others as well. Possibly something like XChat or Pidgin. – dilbert May 09 '14 at 01:46
  • Checkout out this method to minimize windows on Lunix based OSs: http://unix.stackexchange.com/questions/159334/focusing-the-current-window-minimizing-all-of-the-others – Johnny Mar 15 '15 at 10:14

0 Answers0