Selenium 未找到现有元素

Selenium didn't find existing element

我创建了运行 selenium internet explorer webdriver 的应用程序。 该程序在我的电脑上运行良好,但当我在其他电脑上使用相同的驱动程序尝试时 它在第一个元素上抛出异常,说找不到它。

我检查的第一件事是 html pagesource 区别是:

在我的电脑上:

<input name="cId" tabindex="1" id="CNum" type="text" size="13" maxlength="10" value="" autocomplete="off">

在其他电脑上:

<INPUT tabIndex=2 id=CNum maxLength=10 size=13 name=cId autocomplete="off">

我的硒代码:

driver.FindElement(By.Id("CNum")).SendKeys("123");

它可能是什么(html 源在其他计算机上没有类型,在许多情况下没有引号。)

谢谢。

试试

 driver.FindElement(By.name("cId")).SendKeys("123"); or
 driver.findelement(by.cssselector("input[name='cId']")).sendkeys("123");