Being new to the framework, I couldn't understand the difference if I create a keyword using 'Get Library Instance' in RF. Please explain with an example or any reference document. It's a bit confusing for me.
I have already visited: BuiltIn.Get Library Instance
Edited: Referring to the above link, I can see that the custom method uses "BuiltIn.Get Library Instance" to find the title on a page. So, what is the difference if I write my own keyword in Robot Framework using Get Title having same functionality as title_should_start_with or writing the same method in python using Inheritance as explained 1) here and 2) here.
code:
1) Using Inheritance
from SeleniumLibrary import SeleniumLibrary
class ExtendedSeleniumLibrary(SeleniumLibrary):
def title_should_start_with(self, expected):
title = self.get_title()
if not title.startswith(expected):
raise AssertionError("Title '%s' did not start with '%s'"
% (title, expected))
2) Using get_library_instance
from robot.libraries.BuiltIn import BuiltIn
def title_should_start_with(expected):
seleniumlib = BuiltIn().get_library_instance('SeleniumLibrary')
title = seleniumlib.get_title()
if not title.startswith(expected):
raise AssertionError("Title '%s' did not start with '%s'"
% (title, expected))
3) RF keyword
*** Settings ***
Library SeleniumLibrary
*** keywords ***
Verify Title
${title} Get Title
.
.