diff options
Diffstat (limited to 'crocoite')
-rw-r--r-- | crocoite/behavior.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/crocoite/behavior.py b/crocoite/behavior.py index 8c24c59..119248e 100644 --- a/crocoite/behavior.py +++ b/crocoite/behavior.py @@ -114,10 +114,12 @@ class JsOnload (Behavior): def onload (self): yield self.script - self.scriptHandle = self.loader.tab.Page.addScriptToEvaluateOnNewDocument (source=str (self.script))['identifier'] + result = self.loader.tab.Page.addScriptToEvaluateOnNewDocument (source=str (self.script)) + self.scriptHandle = result['identifier'] def onstop (self): - self.loader.tab.Page.removeScriptToEvaluateOnNewDocument (identifier=self.scriptHandle) + if self.scriptHandle: + self.loader.tab.Page.removeScriptToEvaluateOnNewDocument (identifier=self.scriptHandle) yield from () ### Generic scripts ### |