Nikunj Nikunj - 4 months ago 55
Java Question

How to Access Model Dialog Box content developed in Bootstrap using Selenium Web Driver and Java

I am trying to access model dialogue box (developed in Bootstrap) using Selenium Web Driver in Java, I am unable to do so. Here i wan tot access Title, Content and Button.

One more point is here xPath is dynamic, every time xPath is generating differently. I know that can be solved by partially matching the xPath.

So help me to solve this problem. Here I am attaching image of my model box design.

enter image description here

Here is code snippet

enter image description here

Here is code

<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>

Answer
//div[@class="bootstrap-dialog-title"] for Title

//div[@class="bootstrap-dialog-message"] for message

//div[@class="bootstrap-dialog-footer-buttons"]/button for buttton
Comments