Reputation: 4346
I was trying to pass a web driver element as a parameter to a keyword and got the exeption in the execution log:
[ ERROR ] Calling listener method 'start_keyword' of listener '/usr/local/lib/python2.7/dist-packages/robotide/contrib/testrunner/TestRunnerAgent.py' failed: TypeError: <selenium.webdriver.remote.webelement.WebElement object at 0x7f686eb02390> is not JSON serializable
[ ERROR ] Calling listener method 'end_keyword' of listener '/usr/local/lib/python2.7/dist-packages/robotide/contrib/testrunner/TestRunnerAgent.py' failed: TypeError: <selenium.webdriver.remote.webelement.WebElement object at 0x7f686eb02390> is not JSON serializable
Tests still pass, so this doesn't affect the result, but seeing this in a log is not nice. Besides, I don't understand, why it works if all keywords argument are serialized before passing them to actual Python code, and this one is not serializable.
Question: can I pass non-serializable arguments in RobotFramework? For now I'm trying to send not an element, but a named tuple of the element identifiers.
The code I use:
class ElementKeywords(object):
def has_text(self, element):
return bool(self.get_element_property(element, 'text'))
def wait_until_result(self, timeout, poll_period, func, *args):
time_spent = 0
timeout = convert_time(timeout)
poll_period = convert_time(poll_period)
result = False
thrown_exception = None
while True:
try:
result = func(*args)
thrown_exception = None
except Exception as exc:
result = False
thrown_exception = exc
if result or poll_period > timeout or time_spent > timeout:
break
time_spent += poll_period
time.sleep(poll_period)
if result:
return True
if thrown_exception:
raise thrown_exception
msg = 'Failed to receive positive result from {func} in {timeout} ' \
'seconds'.format(func=func.__name__, timeout=str(timeout))
raise TimeoutError(msg)
Test case code:
*** Settings ***
Test Setup Web Setup
Test Teardown Web Teardown
Resource web_resources.txt
*** Test Cases ***
Check Index
[Tags] US123456
Web Login
Clean Redis
${job_id}= Create Pool
Web Refresh
${data_pool_element}= Get Element By Xpath //div[@id="progress-pool"]/div[1]
Wait Until Result 20 1 Has Text ${data_pool_element}
Validate Pool ${job_id}
Upvotes: 0
Views: 385
Reputation: 386010
The problem isn't in your code. You can pass non-serializable objects. The RIDE test runner appears to have a bug. Try running your testcase from a command prompt and the problem should go away.
Upvotes: 1