我是新使用Selenium 2(通过Firefox插件) - 我还没有在网络上的其他地方找到这个答案。Selenium 2验证SCRIPT标记
是否有可能验证<script>
元素是目前在页面代码?
我需要经常检查一些需要一系列脚本的网页脚本块元素链接和页面。我一直没能弄清楚这一部分。一个示例是检查脚本是否在页面上。 下面是预计的样本代码:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||'
function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'xx-x-0000-00', 'somedomain.com');
</script>
预先感谢您!
这个答案建议你可以使用'getAttribute(“innerHTML”)':http://stackoverflow.com/questions/20497607/how-to-get-the-contents-of-a-script-tag- in-selenium – Richard
我正在使用Selenium IDE Firefox插件来创建HTML脚本。如何/将在哪里包括使用getAtribute? – photoman
有没有人有解决方案? @理查德 - 你能详细说一下吗? – photoman