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