我收到以下錯誤Internet explorer 8
但Firefox
工作相同(這兩個名字,XPath的相同)硒的webdriver元素沒有發現錯誤在Internet Explorer
"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
特別..
感謝, Vishwas
請提供實際的HTML。你提供的不是HTML。 – Arran
@Arran ...兩個文本框有「用戶名」和「密碼」。我想在這些文本框中輸入字符串。我得到錯誤,該名稱或xpath元素是在Internet Explorer中找不到.. PS:它在Firefox中工作。 –
什麼版本的Firefox?什麼版本的Selenium?什麼版本的IE驅動程序?什麼OS? – Arran