Reputation: 59
I have a custom library in Robot Framework and I am trying to pass id of some web element and perform operation on the same.
from robot.libraries.BuiltIn import BuiltIn
class mylibrary:
def get_webdriver_instance(self):
return BuiltIn().get_library_instance('SeleniumLibrary')
def sendkeys_value(self,ele,value):
driver = self.get_webdriver_instance()
element = driver.find_element_by_id(ele)
element.send_keys(value)
When call sendkeys_value in Robot Framework its throwing error as Attribute Error: 'SeleniumLibrary' object has no attribute 'find_element_by_id'
Upvotes: 1
Views: 144
Reputation: 20077
That's because your driver
object is a reference to the SeleniumLibrary itself, while it has a property driver
itself, which is the actual selenium library. A lot of drivers repeated :) , it's probably easier to explain with an example:
driver = self.get_webdriver_instance().driver
Upvotes: 3