【问题标题】:Selenium getting the property of an object JSSelenium 获取对象 JS 的属性
【发布时间】:2017-07-11 21:05:51
【问题描述】:

解释我的问题的最简单方法是提供一张我正在尝试检索的图片:

我正在尝试使用 selenium 获取路径为“data.source.displayName”的 data 的源节点,但我不能简单地检索此信息。我可以检索有关 HTML 元素第一层的信息,例如“textContent”,但每当我对对象执行 id.getAttribute 时,它​​只会返回 null。一些示例代码:

var data = identity.getAttribute('__data__.source.displayName');
                                       data.then(function(classes){
                                        console.log(classes);
                                       }); /*this will print out null*/

var data = identity.getAttribute('textContent');
                                       data.then(function(classes){
                                        console.log(classes);
                                       }); /* this prints out "node_15 → node_20" and works correctly*/

【问题讨论】:

    标签: javascript selenium object properties getattribute


    【解决方案1】:

    如果没有更多代码,有点难以判断到底发生了什么,但您的图片实际上显示的是 SVG 标签。可能是您当前工作的环境不支持您尝试这样做的方式。也许这个有帮助:Read Attributes of SVG-Elements in HTML via JS

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多