過去に Selenium RC を使用したことがありますが、webdriver は初めてです。アプリには 3 つのリンクがあります。通知、メッセージ、接続。通知をクリックすると、通知ドロップボックスが表示されます。メッセージをクリックすると、メッセージ ドロップ ボックスが表示され、接続をクリックすると、接続ドロップ ボックスが表示されます。スクリプトでは、通知リンクをクリックし、通知ドロップ ボックスを待ってから、通知ドロップボックスをアサートします。メッセージと接続の順序についても同じです。通知シーケンスは正しく機能します。メッセージでは、メッセージ リンクをクリックしてから、メッセージ ドロップ ボックス リンクを待機してハングします。すべての行の後に print コマンドを置いたので、これを知っています。これが私のコードです:
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 を使用しています。3.6、7、11、13、15、16 など、さまざまなバージョンの FF を試しましたが、どれも機能しませんでした。また、スクリプトがハングするだけです。Eclipseでエラーをスローすることさえありません。スクリプトを約 11 時間実行したことがありますが、それでもエラーは発生しませんでした。
この問題を解決するためにさらに情報が必要な場合はお知らせください。
ありがとう!