source: main/waeup.sirp/branches/multimechanize/trunk/examples/test_scripts/example_mechanize_simple.py @ 7541

Last change on this file since 7541 was 7541, checked in by uli, 13 years ago

Add sources copied from current multi-mechanize GIT repos.

File size: 780 bytes
Line 
1#
2#  Copyright (c) 2010 Corey Goldberg (corey@goldb.org)
3#  License: GNU LGPLv3
4#
5#  This file is part of Multi-Mechanize
6#
7
8
9import mechanize
10import time
11
12
13
14class Transaction(object):
15    def __init__(self):
16        self.custom_timers = {}
17
18    def run(self):
19        br = mechanize.Browser()
20        br.set_handle_robots(False)
21
22        start_timer = time.time()
23        resp = br.open('http://www.example.com/')
24        resp.read()
25        latency = time.time() - start_timer
26
27        self.custom_timers['Example_Homepage'] = latency
28
29        assert (resp.code == 200), 'Bad HTTP Response'
30        assert ('Example Web Page' in resp.get_data()), 'Failed Content Verification'
31
32
33if __name__ == '__main__':
34    trans = Transaction()
35    trans.run()
36    print trans.custom_timers
Note: See TracBrowser for help on using the repository browser.