Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions docs/extending/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions src/SeleniumLibrary/base/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ def element_finder(self):
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`.

Expand Down
12 changes: 12 additions & 0 deletions utest/test/api/plugin_with_event_firing_webdriver.py
Original file line number Diff line number Diff line change
@@ -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')
6 changes: 6 additions & 0 deletions utest/test/api/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,9 @@ def test_plugin_as_last_in_init(self):
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')