Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit of event listener to auto do record

  • Loading branch information...
commit 2f9c1b28f183beb5ab5c810d41be66061bc07015 1 parent e7f416c
@AutomatedTester authored
Showing with 34 additions and 0 deletions.
  1. +34 −0 browsermobproxy/webdriver_event_listener.py
View
34 browsermobproxy/webdriver_event_listener.py
@@ -0,0 +1,34 @@
+from selenium.webdriver.support.abstract_event_listener import AbstractEventListener
+
+class WebDriverEventListener(AbstractEventListener):
+
+ def __init__(self, client, refs={}):
+ self.client = client
+ self.hars = []
+ self.refs = refs
+
+ def before_navigate_to(self, url, driver):
+ if len(self.hars) != 0:
+ self.hars.append(self.client.har)
+ self.client.new_har("navigate-to-%s" % url, self.refs)
+
+ def before_navigate_back(self, driver=None):
+ if driver:
+ name = "-from-%s" % driver.current_url
+ else:
+ name = "navigate-back"
+ self.client.new_page(name)
+
+ def before_navigate_forward(self, driver=None):
+ if driver:
+ name = "-from-%s" % driver.current_url
+ else:
+ name = "navigate-forward"
+ self.client.new_page(name)
+
+ def before_click(self, element, driver):
+ name = "click-element-%s" % element.id
+ self.client.new_page(name)
+
+ def before_quit(self, driver):
+ self.hars.append(self.client.har)
Please sign in to comment.
Something went wrong with that request. Please try again.