javascript - 在 raiseevent() 方法中存储 HTML 对象(div 元素) - Pepper robo
问题描述
在胡椒机器人平板电脑中,我必须在单击按钮时在 webview 中显示网页。
如何在方法中存储对象(htmldiv
元素)raiseevent()
例如:session.raiseevent("eventname", "htmldivelement")
下面的python函数加载url和webview
def web_view(self):
url = "https://www.google.com"
try:
self.ts.loadUrl(url)
self.ts.showWebview()
#self.showWebview("https://www.google.com")
except Exception, e:
self.logger.info("Error while loading tablet: {}".format(e))
解决方案
您不能请求在 Pepper 的平板电脑上显示任意 html。
有两种方法可以从 Python 更新 Pepper 的平板电脑:
- 加载一个新网页
ALTabletService.showWebview(url)
- 有一个使用javascript SDK订阅 ALMemory 事件的网页,并使用有关新平板电脑状态的信息引发 almemory 事件(这些通常传递 json,但也可以发送 html 任何其他格式 - 无论如何,你必须用javascript处理它)。在robots-jumpstarter中有一些例子。
推荐阅读
- python - 如何在 selenium python 中修复 StaleElementReferenceException
- python - 如何在 HTML 页面上呈现 Python 猜数字游戏
- for-loop - 我可以在其中使用 awk '!seen[$0]' 执行“for 循环”以应用于多个 .txt 文件吗?
- azure - 认知服务 - 人脸识别 - 错误识别模型'不兼容
- javascript - 关于如何为 mochajs npm 测试调用路由的问题
- arrays - Ruby - 将一个数组中的项逐一除以不同数组的项,然后抛出一个新数组
- flutter - How to set the inactive color of the RadioListTile in flutter?
- arrays - 如何在不使用另一个数组的情况下从数组中删除重复项?
- sql - 使用最小/最大的子查询
- python - ValueError:字典包含不在字段名中的字段:'timestamp'