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
18 changes: 18 additions & 0 deletions test/acceptance/extending.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
*** Settings ***
Suite Setup Extending Suite Setup
Suite Teardown ExtSeLib.Close All Browsers
Resource resource.robot
Library ExtSL.ExtSL WITH NAME ExtSeLib


*** Test Cases ***
When Extending SeleniumLibrary Keywords With Decorated Name Can Be Used For Extending
${elements} = ExtSeLib.Ext Web Element //tr
Should Not Be Empty ${elements}

When Extending SeleniumLibrary Keywords With Method Name Can Be Used For Extending
ExtSeLib.Ext Page Should Contain Email:

*** Keywords ***
Extending Suite Setup
ExtSeLib.Open Browser ${ROOT}/forms/prefilled_email_form.html ${BROWSER}
13 changes: 13 additions & 0 deletions test/resources/testlibs/ExtSL.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from SeleniumLibrary import SeleniumLibrary
from SeleniumLibrary.base import keyword


class ExtSL(SeleniumLibrary):

@keyword
def ext_web_element(self, locator):
return self.get_webelements(locator)

@keyword
def ext_page_should_contain(self, text):
self.page_should_contain(text)
32 changes: 32 additions & 0 deletions test/unit/api/test_accessing_keywod_methods.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import unittest

from SeleniumLibrary import SeleniumLibrary


class KeywordsMethodsTests(unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.selib = SeleniumLibrary()

def test_kw_with_method_name(self):
self.assertTrue(self.selib.keywords['add_cookie'])
self.assertTrue(self.selib.attributes['add_cookie'])
self.assertTrue(self.selib.keywords['page_should_contain_image'])
self.assertTrue(self.selib.attributes['page_should_contain_image'])
self.assertTrue(self.selib.keywords['xpath_should_match_x_times'])
self.assertTrue(self.selib.attributes['xpath_should_match_x_times'])

def test_kw_with_methods_name_do_not_have_kw_name(self):
with self.assertRaises(KeyError):
self.selib.keywords['Add Cookie']
with self.assertRaises(KeyError):
self.selib.keywords['Page Should Contain Image']
with self.assertRaises(KeyError):
self.selib.keywords['Xpath Should Match X Times']

def test_kw_with_decorated_name(self):
self.assertTrue(self.selib.attributes['get_webelement'])
self.assertTrue(self.selib.keywords['Get WebElement'])
self.assertTrue(self.selib.attributes['get_webelements'])
self.assertTrue(self.selib.keywords['Get WebElements'])