我遇到以下错误,Internet explorer 8
但工作相同Firefox
(两个名称,xpath 相同)
"Unable to find element with name == username (WARNING: The server did not provide any stacktrace information)"
我的 HTML 看起来像
<class=form>User Name
<INPUT tabIndex=0 size=22 name=username autocomplete="off"\>
class=form>Password
<INPUT tabIndex=0 onkeypress="checkCapsLock( event )" value="" size=22 type=password name=password autocomplete="off\>
我的 JAVA 代码:
File file = new File("D:/vishwas/Selenium/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
WebDriver driver = new InternetExplorerDriver();
driver.get("http://10.26.210.74:9080/cbaUserAdmin/");
WebElement Name = driver.findElement(By.xpath("//input[@name='username']"));
Name.sendKeys(new String[]{"username"});
WebElement Pass = driver.findElement(By.xpath("//input[@name='password']"));
Pass.sendKeys(new String[]{"password"});
此页面的完整 HTML 代码:
<table bgcolor="#ffffd0" cellPadding="1" cellSpacing="1" border=0 >
<tr>
<td width="5%"> </td>
<td width="30%"> </td>
<td width="65%"> </td>
</tr>
<tr>
<td> </td>
<td colspan="2">
<FONT SIZE="3"><B>Log on</B></FONT>
</td>
<td> </td>
</tr>
<tr><td colspan=4> </td></tr>
<tr>
<td> </td>
<td class="form">User Name</td>
<td class="form">
<input type="text" tabindex="0" size="22" name="username" autocomplete="off" />
</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td class="form">Password</td>
<td class="form">
<input type="password" tabindex="0" name="password" size="22" autocomplete="off" onKeyPress="checkCapsLock( event )"/>
<!--<span id="spanCaps" class="PopupBox" style="margin-left:10;vertical-align:bottom;">Caps Lock is <b>ON</b></span>-->
</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td class="form" >
<span id="spanCaps" class="PopupBox">Caps Lock is <b>ON</b></span>
<input type="submit" name="submit" tabindex="0" value="Login">
请帮我解决这个问题,因为我想知道为什么我会Internet explorer
特别加入..
谢谢,维什瓦斯