我以前使用过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