私はSeleniumとjavaを使用していますので、モーダル内の要素をクリックすることはできません。 シナリオは フレーム内のアイテムをクリックした後、モーダルを開き、このモーダル内の要素をクリックする必要がありますが、それを得ることはできません。Selenium - モーダル内の要素をクリックできません
<div class="modal-dialog">
<div class="modal-content modal-custom-content">
<div class="modal-header">
...
</div>
<div class="modal-body">
<form id="formTo" class="form-container">
<div class="row">
...
</div>
<div class="small-space"></div>
<input ...>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
...
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
...
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
...
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
...
</div>
</div>
<div class="small-space"></div>
<div class="row">
...
</div>
</form>
</div>
<div class="small-space"></div>
<div class="modal-footer">
<div class="row text-center">
<div class="col-md-6 col-sm-6 col-xs-12">
<button class="btn modal-button full-btn" id="saveexit" type="button">SAVE AND EXIT</button>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
...
</div>
</div>
</div>
</div>
</div>
が、これは次のとおりです。ここで
while (itr.hasNext()) {
String popup = itr.next();
System.out.println("itr: " + popup);
driver.switchTo().window(popup);
}
は私のモーダルのhtmlです:私もswitchTo()この方法で試してみました
js.executeScript("document.getElementById('saveexit').scrollIntoView(true);");
:
は、私はすでにしてみましたfirefox devツールから取得したCSSパス:
html.no-touch body div.remodal-wrapper.remodal-is-opened div.modaliAdesione.remodal.remodal-is-initialized.remodal-is-opened div.modal-dialog div.modal-content.modal-custom-content div.modal-footer div.row.text-center div.col-md-6.col-sm-6.col-xs-12 button#saveexit.btn.modal-button.full-btn
オブジェクトが見つかりません。
- 質問1:要素がモーダル内にある場合は、 の別の方法で管理する必要がありますか?
- 質問2:最終的にボタンをクリックする方法 saveexitが機能しますか?ここ
HTMLのコードスニペットを共有している:ここではhttps://codeshare.io/arLW9q
は、Javaコードです:
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=\"saveexit\"]")))
私もして試してみました:
cssSelector: #saveexit
cssPath: html.no-touch body div.remodal-wrapper.remodal-is-opened div.modaliAdesione.remodal.remodal-is-initialized.remodal-is-opened
div.modal-dialog div.modal-content.modal-custom-content div.modal-footer div.row.text-center div.col-md-6.col-sm-6.col-xs-12
button#saveexit.btn.modal-button.full-btn
xpath: //*[@id="saveexit"]
注意してください。ブラウザのコンソールからdocument.getElementById('saveexit').click();
を実行すると、それは動作します
モーダルに切り替えることができるウィンドウではありません。それはページのHTMLだけです。どのJavaコードを試してみましたか?結果は何ですか?エラーメッセージなど – JeffC
私が試したJavaコードはjs.executeScriptです。結果はsaveexitが存在しないというエラーです。 – eeadev