2016-04-28 19 views
1

這裏的幫助下,使用Button類中硒的webdriver是我的代碼:如何在Java

<div class="meal_buton_cont"> 
<button class="pink_button" data-target="#myModal" data-toggle="modal">Add Selected to Shopping List</button> 
<button id="add_meal" class="gray_button">+ Add Meal</button> 
</div> 

我使用這個:

driver.findElement(By.className("pink_button")).click(); 

但沒有彈出打開,但一段時間後打開,但不項目採取,它顯示空白。

如何創建腳本點擊Pink_button然後我的彈出窗口會打開?

的元素會出現使用明確的等待像WebDriverWait API之前,請幫我

+0

爲您的頁面的html內容添加一些更多詳細信息。 手動點擊粉紅色按鈕時是否出現彈出窗口? – ParasuRam

回答

1

幾件事情consider..Wait。一旦元素可點擊使用ExpectedConditions.elementToBeclickable(WebElement)然後點擊它並再次等待彈出窗口出現。如果其警報然後使用ExpectedConditions.alsertIsPresent()WebDriverWait