2016-03-28 13 views
0

それぞれ開いているアラートからテキストを取得しようとしています。予期しないアラートが開いているクロームドライバ

私は自動化のためにChromeDriverを使用しています。

は、ここに私のコードです:

System.out.println("Requesting to be Share as Only"); 
WebElement lnkShare = driver.findElement(By.xpath("//*[@id='lnkRequest']")); 
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", lnkShare); 
lnkShare.click(); 
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='lnkShare']"))); 
driver.findElement(By.xpath("//*[@id='lnkShare']")).click(); 
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//*[@id='ctl00_Dashboard_ucProgressbar_imgLoader']"))); 
driver.switchTo().frame("fbContent"); 
driver.findElement(By.xpath("//*[@id='ctl00_ContentPlaceHolder1_rdoRequestShareOnly']")).click(); 
driver.switchTo().alert().accept(); 
String alertText = alert.getText(); 
driver.switchTo().alert().accept(); 
System.out.println("getting in if loop"); 

if (alertText.contains("Net Size/Gross Size")) { 
    System.out.println("Present"); 
} else { 
    System.out.println("not"); 
} 

System.out.println("out of loop");But I get the following error : 

org.openqa.selenium.UnhandledAlertException:予期しない警告オープン: {アラートテキスト:エラーattemptionを共有したときに検出されました!次 フィールド不足している:。ネットサイズ/総サイズベンダーが再び を確認してみてください}

問題がありますか?

答えて

0

私はそれを見つけました、問題は、要素が配置された別のiframeがあったことでした。

関連する問題