「x」ボタンをクリックしてYoutubeポップアップウィンドウを閉じようとしましたが、次のエラーメッセージが表示されます。 org.openqa.selenium.ElementNotVisibleException:によって引き起こさ「x」をクリックしてYouTubeポップアップウィンドウを閉じるには、Selenium WebDriverを使用していません。
の要素は、現在表示されていない あるので、蛇腹コード試み
と相互作用しなくてもよい。
driver.findElement(By.className("close")).click();
driver.findElement(By.xpath("//button[@class='close']")).click();
driver.findElement(By.cssSelector("button[class='close']")).click();
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();",
driver.findElement(By.className("close")));
HTML:
<div id="videoModal" class="modal fade in" aria-hidden="true" aria-labelledby="videoModal" role="dialog" tabindex="-1" style="display: block;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<button class="close" aria-hidden="true" data-dismiss="modal" type="button">×</button>
<div>
<iframe width="100%" height="350" allowfullscreen="" src="https://www.youtube.com/embed/SQFKxxKMIxc?autoplay=1"/>
</div>
スクリーンショット: https://i.stack.imgur.com/W3IXe.png
public Boolean closeVideoPopup(){
try{
driver.findElement(By.id("video-how-to")).click();
driver.waitForPageLoad();
driver.findElement(By.className("close")).click();
return true;
}
catch(Exception e) {
logger.info("Exception occurred: "+ e.getMessage().toString().substring(0, Integer.parseInt(TestConstants.ERRCHARCOUNT)));
}
return false;
}
をクリックしましょう**は私たちにどのを示す考えることができます'x'ボタン**あなたはあなたの作品の一部を参考にしてくれていますか?ありがとう – DebanjanB
@AakashSinghあなたがクリックしようとしている** x **を '検査した後に、ポップアップの印刷画面を追加することもできます。 – iamdanchiv
@Devスクリーンショットのリンクと私が書いたコードを追加しました。 –