I have one client who is using Django’s default session support which means they get cookied upon authentication. The vast majority of the coverage we’re getting with Se is going to be run in Linux/Firefox, but there are some IE specific components that we need to tackle as well.
Firefox starts with a completely separate process/profile so sharing the cookie across browsers doesn’t happen. But with IE things can get pretty annoying if there is an open IE window that is logged in as User A and a script says to open a window and login as User B. The problem is that the cookie is shared between the windows so the new browser starts with being logged in as User A.
Now the script will kill all running iexplore.exe processes before launching a new one. (Well, depending on a config parameter that is; but the default is to do it.)
if self.cf.get("Selenium", "browser") == "*iexplore" and self.cf.getboolean("General", "clean_ie_sessions"): import win32_utilities win32_utilities.nuke_all_ie() self.selenium = wrapper().connect(self.cf.get("Selenium", "server_host"), \ self.cf.get("Selenium", "server_port"), \ self.cf.get("Selenium", "browser"), \ self.cf.get("Selenium", "base_url"))
import win32api, win32pdhutil, win32con def nuke_all_ie(): try: win32pdhutil.FindPerformanceAttributesByName("Process", "ID Process", "iexplore") except: pass pids = win32pdhutil.FindPerformanceAttributesByName("iexplore") if len(pids) > 0: for p in pids: handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, p) win32api.TerminateProcess(handle,0) win32api.CloseHandle(handle)
In the credit-given-when-due department, I got the inspiration for this code from