[英]How to write the script for the check box in Selenium web driver by using Java
[英]How to Access Model Dialog Box content developed in Bootstrap using Selenium Web Driver and Java
我正在嘗試使用Java中的Selenium Web Driver訪問模型對話框(由Bootstrap開發)。 在這里,我想訪問標題,內容和按鈕。
還有一點是,每次xPath生成不同時,xPath都是動態的。 我知道可以通過部分匹配xPath來解決。
所以幫我解決這個問題。 在這里,我將附加我的模型盒設計的圖像。
這是代碼片段
這是代碼
<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 class="bootstrap-dialog-title" id="5f663313-d82d-4ab8-9712-6665e80a3654_title">
Member Registration
</div>
</div>
</div>
<div class="modal-body">
<div class="bootstrap-dialog-body">
<div class="bootstrap-dialog-message">
Sample Message Sample Message Sample Message Sample Message Sample Message Sample Message.
</div>
</div>
</div>
<div class="modal-footer">
<div class="bootstrap-dialog-footer">
<div class="bootstrap-dialog-footer-buttons">
<button class="btn btn-primary" id="353ab962-44d3-497f-8318-6db703b460d8">
Ok
</button>
</div>
</div>
</div>
</div>
</div>
//div[@class="bootstrap-dialog-title"] for Title
//div[@class="bootstrap-dialog-message"] for message
//div[@class="bootstrap-dialog-footer-buttons"]/button for buttton
driver.switchTo().activeElement();
Thread.sleep(5000);
driver.findElement(By.xpath("//button[contains(text(),'"+data+"')]")).click();
此解決了我的問題,我也想訪問消息,但我無法訪問
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.