我是新使用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