Repository: robotframework/SeleniumLibrary

Issue:
Add better support for plugin to add event firing WebDriver
For plugins, it would be easier to do something like this:
```
class MyPlugin(LibraryComponent):

    def __init__(self, ctx):
        LibraryComponent.__init__(self, ctx)
        self.event_firing_webdriver  = WhatEverYouWant
```

Comments:

Patch:
diff --git a/docs/extending/extending.rst b/docs/extending/extending.rst
index d143e884..9b521229 100644
--- a/docs/extending/extending.rst
+++ b/docs/extending/extending.rst
@@ -217,15 +217,16 @@ log                        Wrapper to ``robot.api.logger.write`` method.
 
 Also following attributes are available from the ``LibraryComponent`` class:
 
-==============  =====================================================================
-  Attribute                              Description
-==============  =====================================================================
-driver           Currently active browser/WebDriver instance in the SeleniumLibrary.
-drivers          `Cache`_ for the opened browsers/WebDriver instances.
-element_finder   Read/write attribute for the `ElementFinder`_ instance.
-ctx              Instance of the SeleniumLibrary.
-log_dir          Folder where output files are written.
-==============  =====================================================================
+======================  ==============================================================================
+      Attribute                                          Description
+======================  ==============================================================================
+driver                  Currently active browser/WebDriver instance in the SeleniumLibrary.
+drivers                 `Cache`_ for the opened browsers/WebDriver instances.
+element_finder          Read/write attribute for the `ElementFinder`_ instance.
+ctx                     Instance of the SeleniumLibrary.
+log_dir                 Folder where output files are written.
+event_firing_webdriver  Read/write attribute for the SeleniumLibrary `EventFiringWebDriver`_ instance.
+======================  ==============================================================================
 
 See the `SeleniumLibrary init`_, the `LibraryComponent`_ and the `ContextAware`_ classes for further
 implementation details.
diff --git a/src/SeleniumLibrary/base/context.py b/src/SeleniumLibrary/base/context.py
index d215441d..47f9ab6d 100644
--- a/src/SeleniumLibrary/base/context.py
+++ b/src/SeleniumLibrary/base/context.py
@@ -43,6 +43,14 @@ class ContextAware(object):
     def element_finder(self, value):
         self.ctx._element_finder = value
 
+    @property
+    def event_firing_webdriver(self):
+        return self.ctx.event_firing_webdriver
+
+    @event_firing_webdriver.setter
+    def event_firing_webdriver(self, event_firing_webdriver):
+        self.ctx.event_firing_webdriver = event_firing_webdriver
+
     def find_element(self, locator, tag=None, required=True, parent=None):
         """Find element matching `locator`.
 


Test patch:
diff --git a/utest/test/api/plugin_with_event_firing_webdriver.py b/utest/test/api/plugin_with_event_firing_webdriver.py
new file mode 100644
index 00000000..8dbf13c7
--- /dev/null
+++ b/utest/test/api/plugin_with_event_firing_webdriver.py
@@ -0,0 +1,12 @@
+from SeleniumLibrary.base import LibraryComponent, keyword
+
+
+class plugin_with_event_firing_webdriver(LibraryComponent):
+
+    def __init__(self, ctx):
+        LibraryComponent.__init__(self, ctx)
+        self.event_firing_webdriver = 'event_firing_webdriver'
+
+    @keyword
+    def tidii(self):
+        self.info('foo')
diff --git a/utest/test/api/test_plugins.py b/utest/test/api/test_plugins.py
index d84a8d16..b9aa4cb4 100644
--- a/utest/test/api/test_plugins.py
+++ b/utest/test/api/test_plugins.py
@@ -109,3 +109,9 @@ class ExtendingSeleniumLibrary(unittest.TestCase):
         event_firing_wd = os.path.join(self.root_dir, 'MyListener.py')
         sl = SeleniumLibrary(plugins=plugin_file, event_firing_webdriver=event_firing_wd)
         self.assertEqual(sl.event_firing_webdriver, 'should be last')
+
+    def test_easier_event_firing_webdriver_from_plugin(self):
+        plugin_file = os.path.join(self.root_dir, 'plugin_with_event_firing_webdriver.py')
+        sl = SeleniumLibrary(plugins=plugin_file)
+        self.assertEqual(sl._plugin_keywords, ['tidii'])
+        self.assertEqual(sl.event_firing_webdriver, 'event_firing_webdriver')