JavascriptExecutor 的 executeScript() 方法的返回类型是什么? [英] What is the return type of executeScript() method of JavascriptExecutor?

查看:42
本文介绍了JavascriptExecutor 的 executeScript() 方法的返回类型是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果网页上的 JavaScript 返回非十进制值,那么 javascriptExecuter.executeScript() 将返回什么?

If a JavaScript on a web page return non-decimal value then what will javascriptExecuter.executeScript() will return?

有人能回答这个问题吗?

Ccan anyone answer this question?

推荐答案

executeScript()

executeScript() 在当前选定的框架或窗口的上下文中执行 JavaScript.提供的脚本片段将作为匿名函数的主体执行.

executeScript()

executeScript() executes a JavaScript in the context of the currently selected frame or window. The script fragment provided will be executed as the body of an anonymous function.

如果脚本有返回值(即如果脚本包含返回语句),则返回以下类型的对象:

If the script has a return value (i.e. if the script contains a return statement), then the following type of objects are returned:

  • 对于 HTML 元素,此方法返回一个 WebElement
  • 对于小数,返回一个Double
  • 对于非十进制数,返回一个Long
  • 对于布尔值,返回一个 Boolean
  • 对于所有其他情况,返回一个 String.
  • 对于数组,按照上述规则,每个对象都会返回一个 List.嵌套列表也受支持.
  • 对于地图,返回一个 Map,其值遵循上述规则.
  • 如果值为null或没有返回值,则返回null
  • For an HTML element, this method returns a WebElement
  • For a decimal, a Double is returned
  • For a non-decimal number, a Long is returned
  • For a boolean, a Boolean is returned
  • For all other cases, a String is returned.
  • For an array, a List is returned with each object following the rules above. Nested lists are also supported.
  • For a map, a Map is returned with values following the rules above.
  • If the value is null or there is no return value, null is returned

这篇关于JavascriptExecutor 的 executeScript() 方法的返回类型是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆