Object of type 'CompatElement' is not JSON serializable
Hi,
I'm trying to use execute script and passing element to the script. The document is not so clear about this except: Arguments to pass to the script. Must be JSON serializable.
So I try:
button = await session.get_element(button_css)
scroll_script = "button.scrollIntoView(false)"
await session.execute_script(scroll_script, {'button': button})
But it turn out Object of type 'CompatElement' is not JSON serializable.
What is correct way to do this?
You should get the button in javascript itself, so something like execute_script("document.querySelector(arguments[0]).scrollIntoView(false)", button_css) should work.
So, I loop through a list of element from get_elements() and do some same process for all of them.
That's why i can not pass the button_css.
Is there anyway i can extract the css/xpath selector of current selected element and pass it to execute_scripts ?