【minium】app.evaluate方法执行js代码报错应该怎么解决?
js = """
var ctx = document.getElementsByClassName(arguments[0]).getContext('2d');
ctx.font = '70px Arial';
ctx.fillText(arguments[1], 10, 50);
"""
canvas = {'selector': 'view.firstCanvas>canvas'}
self.app.evaluate(app_function=js, args=[canvas['selector'], text], sync=True)
如果直接传递元素会报json序列化错误,
TypeError: Object of type BaseElement is not JSON serializable
如果传元素定位会报unexcepted token var;
[E 2024-07-16 14:39:45 minium.Conn6672 connection#661 __on_message] [15f69751-1cc7-47c3-b89a-fe398f822552]: Unexpected token 'var'
业务场景,需要在canvas签署中文汉字,想要通过ctx实现绘制;