简体   繁体   中英

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.

在此处输入图片说明

Here is code snippet

在此处输入图片说明

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>
//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();

This Solve My Problem , I also wants to access Message but i am unable to access

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM