1

这是我的脚本(在 Selenium IDE 中):

storeEval |   var form =window.document.forms[0];

elements = form.elements; for (var i = 0; i < elements.length; i++) 
{window.document.getElementsByTagName("elements").item(i).style.backgroundColor}
| result

这是我的错误:

[error] Threw an exception: window.document.getElementsByTagName("elements").item(i) is null
4

2 回答 2

4

Your code is looking for elements of type element, like this:

<element>Something</element>

but there aren't any in the document.

Did you really mean to search for <element> elements? It looks like the content of your loop wants to be something like this:

elements.item(i).style.backgroundColor
于 2012-06-05T09:35:59.487 回答
2

Instead of this:

window.document.getElementsByTagName("elements").item(i).style.backgroundColor

Just use this:

elements[i].style.backgroundColor

于 2012-06-05T09:38:09.517 回答