如何在Robot Framework中执行JavaScript [英] How to execute JavaScript in Robot Framework
问题描述
下面是我的代码.当我运行它时,它显示一个WebDriverException.如何在Robot Framework中执行JavaScript代码?
Below is my code. When I run this, it shows a WebDriverException. How do I execute JavaScript code in Robot Framework?
此return $(arguments[0]).data('${ToolTip}').options.title
代码在-java Selenium Web驱动程序中运行良好.
This, return $(arguments[0]).data('${ToolTip}').options.title
code is doing well in -java Selenium web driver.
Mouse Over ${CreateTask}
Execute JavaScript return $(arguments[0]).data('${ToolTip}').options.title
推荐答案
请注意,默认情况下,代码将在 Selenium对象本身,因此将引用Selenium对象.使用 窗口指的是您的应用程序的窗口,例如 window.document.getElementById('foo').
Note that, by default, the code will be executed in the context of the Selenium object itself, so this will refer to the Selenium object. Use window to refer to the window of your application, e.g. window.document.getElementById('foo').
所以
Mouse Over ${CreateTask}
Execute JavaScript return window.$(arguments[0]).data('${ToolTip}').options.title
假设有一些库(最有可能是jQuery)实际上理解$
速记.
Assuming there is some library (jQuery most probably) that actually understands the $
shorthand.
这篇关于如何在Robot Framework中执行JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!