[英]Selenium getting the property of an object JS
解释我的问题的最简单方法是提供一张我要检索的图片:
我正在尝试使用硒来获取路径为' data .source.displayName'的数据的源节点,但是我不能简单地检索此信息。 我可以在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*/
如果没有更多代码,很难说清楚到底是什么情况,但是您的图片实际上显示了SVG标签。 可能是您当前正在使用的环境不支持您尝试的方式。 也许这会有所帮助: 通过JS读取HTML中SVG元素的属性 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.