Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 42 lines (36 sloc) 1.297 kB
55d5d86 initial commit
d1ffuz0r authored
1 #!/usr/bin/env python
2
3
4 class WebPool(object):
5 def __init__(self):
6 self.browsers = {}
7 self.result = {}
8 self.actions = {}
99c803f checking by cycle
d1ffuz0r authored
9 self.ignored = ('send_keys', 'get')
55d5d86 initial commit
d1ffuz0r authored
10
11 def start(self):
12 for name, browser in self.browsers.items():
13 try:
14 b = browser()
15 self.browsers[name] = b
16 self.result[name] = b
17 except:
32aaf40 fix tests
d1ffuz0r authored
18 self.result[name] = browser
55d5d86 initial commit
d1ffuz0r authored
19 return self.result
20
21 def stop(self):
22 for name, browser in self.browsers.items():
23 try:
24 browser.quit()
25 finally:
32aaf40 fix tests
d1ffuz0r authored
26 del self.result[name]
55d5d86 initial commit
d1ffuz0r authored
27
664b1b2 get without parameters
d1ffuz0r authored
28 def action(self, action, arg=None):
55d5d86 initial commit
d1ffuz0r authored
29 for name, browser in self.browsers.items():
30 try:
2a86b85 @d1ffuz0r some changes
authored
31 if not self.result[name] or action.startswith('find_'):
55d5d86 initial commit
d1ffuz0r authored
32 self.result[name] = getattr(browser, action)(arg)
664b1b2 get without parameters
d1ffuz0r authored
33 elif not arg:
34 self.result[name] = getattr(self.result[name], action)()
55d5d86 initial commit
d1ffuz0r authored
35 elif action in self.ignored:
36 getattr(self.result[name], action)(arg)
37 else:
38 self.result[name] = getattr(self.result[name], action)(arg)
39 except:
40 pass
41 return self.result
Something went wrong with that request. Please try again.