File tree Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ *** Settings ***
2+ Suite Setup Extending Suite Setup
3+ Suite Teardown ExtSeLib.Close All Browsers
4+ Resource resource.robot
5+ Library ExtSL.ExtSL WITH NAME ExtSeLib
6+
7+
8+ *** Test Cases ***
9+ When Extending SeleniumLibrary Keywords With Decorated Name Can Be Used For Extending
10+ ${elements } = ExtSeLib.Ext Web Element //tr
11+ Should Not Be Empty ${elements }
12+
13+ When Extending SeleniumLibrary Keywords With Method Name Can Be Used For Extending
14+ ExtSeLib.Ext Page Should Contain Email:
15+
16+ *** Keywords ***
17+ Extending Suite Setup
18+ ExtSeLib.Open Browser ${ROOT } /forms/prefilled_email_form.html ${BROWSER }
Original file line number Diff line number Diff line change 1+ from SeleniumLibrary import SeleniumLibrary
2+ from SeleniumLibrary .base import keyword
3+
4+
5+ class ExtSL (SeleniumLibrary ):
6+
7+ @keyword
8+ def ext_web_element (self , locator ):
9+ return self .get_webelements (locator )
10+
11+ @keyword
12+ def ext_page_should_contain (self , text ):
13+ self .page_should_contain (text )
Original file line number Diff line number Diff line change 1+ import unittest
2+
3+ from SeleniumLibrary import SeleniumLibrary
4+
5+
6+ class KeywordsMethodsTests (unittest .TestCase ):
7+
8+ @classmethod
9+ def setUpClass (cls ):
10+ cls .selib = SeleniumLibrary ()
11+
12+ def test_kw_with_method_name (self ):
13+ self .assertTrue (self .selib .keywords ['add_cookie' ])
14+ self .assertTrue (self .selib .attributes ['add_cookie' ])
15+ self .assertTrue (self .selib .keywords ['page_should_contain_image' ])
16+ self .assertTrue (self .selib .attributes ['page_should_contain_image' ])
17+ self .assertTrue (self .selib .keywords ['xpath_should_match_x_times' ])
18+ self .assertTrue (self .selib .attributes ['xpath_should_match_x_times' ])
19+
20+ def test_kw_with_methods_name_do_not_have_kw_name (self ):
21+ with self .assertRaises (KeyError ):
22+ self .selib .keywords ['Add Cookie' ]
23+ with self .assertRaises (KeyError ):
24+ self .selib .keywords ['Page Should Contain Image' ]
25+ with self .assertRaises (KeyError ):
26+ self .selib .keywords ['Xpath Should Match X Times' ]
27+
28+ def test_kw_with_decorated_name (self ):
29+ self .assertTrue (self .selib .attributes ['get_webelement' ])
30+ self .assertTrue (self .selib .keywords ['Get WebElement' ])
31+ self .assertTrue (self .selib .attributes ['get_webelements' ])
32+ self .assertTrue (self .selib .keywords ['Get WebElements' ])
You can’t perform that action at this time.
0 commit comments