我以前使用過selenium RC,但我是webdriver的新手。 我在我的應用程序中有三個鏈接。通知,消息和連接。 單擊通知時,會顯示通知下拉框。在單擊消息時,將顯示消息下拉框,並在單擊連接時顯示連接下拉框。 在腳本中,我單擊通知鏈接,等待通知下拉框,然後斷言通知收件箱。消息和連接依次相同。 通知序列正常工作。在消息中,它會單擊消息鏈接,然後掛起等待消息放置框鏈接。我知道這一點,因爲我已經在每一行之後放置了打印命令。 赫雷什是我的代碼:在IE中運行的Selenium webdriver腳本掛在Firefox中
driver.findElement(By.xpath("//a[@id='notifications-page-button']")).sendKeys("\n");
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@id='notifications-dropdown-list']//li//div[@class='message']")));
Assert.assertTrue(isElementPresent(By.xpath("//div[@id='notifications-dropdown-list']//li//div[@class='message']")), "Notifications drop box was not displayed");
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//a[@id='messages-page-button']")));
driver.findElement(By.xpath("//a[@id='messages-page-button']")).sendKeys("\n");
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@class='sf_messages_list dropdown']//li//div[@class='message']"))); //This is the line where the script hangs. If I remove this line and the next line and continue with just the click commands, they work. But when I have this line and the next, the remaining click commands are not executed
Assert.assertTrue(isElementPresent(By.xpath("//div[@class='sf_messages_list dropdown']//li//div[@class='message']")), "Messages drop box was not displayed");
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("connections-page-button")));
driver.findElement(By.id("connections-page-button")).click()
赫雷什的消息部分中的HTML:
<li class="icon mm open">
<a id="messages-page-button" class="mm" href="#">
<span class="icon"></span>
<span class="badge hidden_elem">
<strong>
<em>0</em>
</strong>
</span>
</a>
<div class="dropdown-holder">
<div class="sf_messages_list dropdown" data-eventprefix="mainmenu_messages">
<div class="tb-dropdown-header">Messages</div>
<div class="tb-dropdown-body" data-url="/messages/dropdown">
<div class="document-title" style="display: none; !important"> - Dropdown Messages</div>
<div id="messages_list_view_76345" class="message-threads-listview">
<ul>
<div class="no_items hidden_elem">
</div>
</div>
<div class="tb-dropdown-footer" style="display: block;">
</div>
<span class="shadow-hide"></span>
</div>
</li>
下面有用於通知部分的HTML:
<li class="icon mm">
<a id="notifications-page-button" class="mm" href="#">
<span class="icon"></span>
<span class="badge hidden_elem">
<strong>
<em>0</em>
</strong>
</span>
</a>
<div class="dropdown-holder">
<div id="notifications-dropdown-list" class="sf_notifications_list dropdown" data-eventprefix="mainmenu_notifications">
<div class="tb-dropdown-header">Notifications</div>
<div class="tb-dropdown-body" data-url="/notifications/dropdown"></div>
<div class="tb-dropdown-footer">
<a class="view_all" href="/notifications/view">View All Notifications</a>
</div>
</div>
<span class="shadow-hide"></span>
</div>
</li>
上面的代碼在IE。所以看起來問題不在於它無法找到元素。 我使用Selenium 2.25.0。我嘗試過各種版本的FF,包括3.6,7,11,13,15和16,但他們都沒有工作。 此外,腳本只是掛起。它甚至不會在eclipse中拋出錯誤。我曾經讓腳本運行了大約11個小時,仍然沒有錯誤。
請讓我知道,以防您需要更多信息來幫助我解決此問題。
謝謝!
經歷正是你的一樣的情況。無法弄清楚該怎麼辦..你解決了這個問題嗎?還是有工作?請幫幫我....! :-( – Mike