I'm creating some custom keywords for robotframework and I'm stuck on a problem.
I've got the following keyword that is working if I give javascript an argument, for example:
from robot.api.deco import keyword
from robot.libraries.BuiltIn import BuiltIn
from SeleniumLibrary import SeleniumLibrary
class roboJSlib:
@keyword('Checkbox select')
def check(self, arg):
driver = BuiltIn().get_library_instance('SeleniumLibrary')._current_browser()
driver.execute_script("document.getElementById('preventivo_privacy_accetto_informative').click()")
I want the script to get "arg" as id, which is defined in robotframework as an argument.
Does anyone know if this is possible?
found the solution:
@keyword('Checkbox select')
def check(self, arg):
driver = BuiltIn().get_library_instance('SeleniumLibrary')._current_browser()
driver.execute_script("document.getElementById('"+arg+"').click()")
Thanks to everyone.