forked from robotframework/SeleniumLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowsercache.py
More file actions
33 lines (26 loc) · 896 Bytes
/
browsercache.py
File metadata and controls
33 lines (26 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from robot.utils import ConnectionCache
class BrowserCache(ConnectionCache):
def __init__(self):
ConnectionCache.__init__(self, no_current_msg='No current browser')
self._closed = set()
@property
def browsers(self):
return self._connections
def get_open_browsers(self):
open_browsers = []
for browser in self._connections:
if browser not in self._closed:
open_browsers.append(browser)
return open_browsers
def close(self):
if self.current:
browser = self.current
browser.quit()
self.current = self._no_current
self._closed.add(browser)
def close_all(self):
for browser in self._connections:
if browser not in self._closed:
browser.quit()
self.empty_cache()
return self.current