我的HTML無法點擊一個彈出按鈕,硒的webdriver與Java
<div id="981bdff3-90a1-4966-ada9-6550b5a963bc" class="modal bootstrap-dialog type-primary fade size-normal in" aria-hidden="false" role="dialog" aria- labelledby="981bdff3-90a1-4966-ada9-6550b5a963bc_title" tabindex="-1" style="display: block; padding-right: 17px;">
<div class="modal-backdrop fade in" style="height: 351px;"></div>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<div class="bootstrap-dialog-header">
<div class="bootstrap-dialog-close-button" style="display: none;">
<button class="close">×</button>
</div>
<div id="981bdff3-90a1-4966-ada9-6550b5a963bc_title" class="bootstrap-dialog-title">Are you sure?</div>
</div>
</div>
<div class="modal-body">
<div class="bootstrap-dialog-body">
<div class="bootstrap-dialog-message">You will lose all data !</div>
</div>
</div>
<div class="modal-footer" style="display: block;">
<div class="bootstrap-dialog-footer">
<div class="bootstrap-dialog-footer-buttons">
<button id="1b0400a9-c69b-429f-9bdd-11112b7cb3a4" class="btn btn-default">Cancel</button>
<button id="3e4fec25-9538-4351-92b1-c7f9f8ce9574" class="btn btn-primary">OK</button>
</div>
</div>
</div>
</div>
</div>
我的Java
package Modules;
import java.util.Iterator;
import java.util.Set;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import Config.config;
public class AddCollectionPoint_Email {
@Test
@Parameters({"DATAPROVIDER"})
public void Addcollection(String DataProvider)
{
config.driver.findElement(By.id("collectionPointsMenu")).click();
config.driver.findElement(By.xpath("//a[@href='addCollectionPoint']")).click();
config.driver.findElement(By.xpath("//a[@data-ng-click='resetEmailCollectionTab()']")).click();
config.driver.findElement(By.xpath("//a[@data-ng-click='resetFtpCollectionTab()']")).click();
**config.driver.findElement(By.xpath("//a[@data-ng-click='resetEmailCollectionTab()']")).click();**
WebElement element = config.driver.findElement(By.xpath("//div[@class='modal-content']")).findElement(By.xpath("//div[@class='modal-footer']"))
.findElement(By.xpath("//div[@class='bootstrap-dialog-footer-buttons']")).findElement(By.xpath("//button[@class='btn btn-primary']"));
JavascriptExecutor executor = (JavascriptExecutor)config.driver;
executor.executeScript("arguments[0].click();", element);
config.driver.findElement(By.xpath("//input[@name='selectedDataProvider']")).sendKeys(DataProvider);
}
}
我不能夠「確定」按鈕,單擊我一個越來越例外元素不可見。 然後我實現了Webdriver等待,但它也不起作用,我得到了時間錯誤。請幫我解決這個問題。我的代碼工作良好,直到雙星標記線。
他提到在WebDriverWait沒有幫助的說明,並導致_TimeoutException_ – Jeremiah