简体   繁体   English

如何使用Selenium Web Driver和Java访问在Bootstrap中开发的模型对话框内容

[英]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. 我正在尝试使用Java中的Selenium Web Driver访问模型对话框(由Bootstrap开发)。 Here i wan tot access Title, Content and Button. 在这里,我想访问标题,内容和按钮。

One more point is here xPath is dynamic, every time xPath is generating differently. 还有一点是,每次xPath生成不同时,xPath都是动态的。 I know that can be solved by partially matching the xPath. 我知道可以通过部分匹配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 此解决了我的问题,我也想访问消息,但我无法访问

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过使用Java为Selenium Web驱动程序中的复选框编写脚本 - How to write the script for the check box in Selenium web driver by using Java 通过Java中的Selenium Web驱动程序处理另存为对话框 - Handle save as dialog box by selenium web driver in java 使用Selenium Web Driver检查IE保存对话框的可见性 - check visibility of IE save dialog box using Selenium Web Driver 如何使用 selenium Web 驱动程序自动化对话框消息的测试用例 - How to automate test cases for a dialog box message using selenium web driver Selenium Web Driver:使用Java处理Confirm Box - Selenium Web Driver : Handle Confirm Box using Java 使用Java检查硒中是否存在模型对话框 - check whether model dialog box is present or not in selenium using java 什么是Bootstrap压延机以及如何从Bootstrap日历中选择日期,该日期仅在使用Java的Selenium Web驱动程序中是只读的 - What is bootstrap calender and how to select a date from bootstrap calendar which is read only in selenium web driver using java 如何使用 selenium java 在对话框中自动滚动 - How to automate scroll in dialog box using selenium java 如何使用Java和Selenium Web驱动程序单击CTRL + P? - How to click CTRL+P using Java and selenium web driver? 如何使用Java和Selenium Web驱动程序循环Webelements列表? - how to loop list of webelements using java and selenium web driver?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM