[英]javascript function returning undefined even though value display in console.log
[英]getEval returning null on Selenium even though javascript returns value in console
我正在使用以下JavaScript在Selenium中运行getEval:
document.getElementById("j_id0:j_id3:mainBlock:j_id40").children[0].children[0].children[0].children[0].children[0].children[0] .children[2].children[0].children[0].children[0] .children[0].children[1];
当我在控制台中运行代码时,它将返回正确的结果。
当我导航到需要定位的元素所在的页面并单击Selenium中的“查找”按钮时,它将查找并突出显示正确的元素。 但是,当我实际上在Selenium中运行该行时-即使导航到正确的页面并仅运行该行时,也会收到一条消息,提示
[error]Threw an exception: document.getElementById(...)is null
我如何使它正常工作?
在实际的JS站点开始并尝试之前,只需包括this.browserbot.getUserWindow()即可。
selenium.getEval("this.browserbot.getUserWindow().document.getElementById("j_id0:j_id3:mainBlock:j_id40").children[0].children[0].children[0].children[0].children[0].children[0] .children[2].children[0].children[0].children[0] .children[0].children[1]")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.