无法在范围报告中查看屏幕截图

时间:2019-06-13 10:21:42

标签: selenium extentreports

我正在使用带有范围报告的POM,并且一切正常,也可以单击以较大尺寸打开的屏幕截图,但根据客户要求,他需要以较大尺寸的屏幕截图而不单击它。我的上级有一些建议,他说我需要删除缩略图,以便缩略图会以更大的尺寸显示,而在我找不到此选项的地方。

<?xml version="1.0" encoding="UTF-8"?>
    <extentreports>
        <configuration>
            <!-- report theme -->
            <!-- standard, dark -->
            <theme>dark</theme>

            <!-- document encoding -->
            <!-- defaults to UTF-8 -->
            <encoding>UTF-8</encoding>

            <!-- protocol for script and stylesheets -->
            <!-- defaults to https -->
            <protocol>https</protocol>

            <!-- title of the document -->
            <documentTitle>Dimension Data Automation Reports</documentTitle>

            <!-- report name - displayed at top-nav -->
            <reportName>Dimension Data - </reportName>

            <!-- report headline - displayed at top-nav, after reportHeadline -->
            <reportHeadline>Test Automation Report</reportHeadline>

            <!-- global date format override -->
            <!-- defaults to yyyy-MM-dd -->
            <dateFormat>yyyy-MM-dd</dateFormat>

            <!-- global time format override -->
            <!-- defaults to HH:mm:ss -->
            <timeFormat>HH:mm:ss</timeFormat>

            <!-- custom javascript -->
            <scripts>
                <![CDATA[
                    $(document).ready(function() {

                    });
                ]]>
            </scripts>

            <!-- custom styles -->
            <styles>
                <![CDATA[

                ]]>
            </styles>
        </configuration>
    </extentreports>

    public class ExtentManager {
        private static ExtentReports extent;

        public static ExtentReports getInstance() {
            if (extent == null) {
                Date d = new Date();
                //String fileName = d.toString().replace(":", "_").replace(" ", "_") + ".html";
                String fileName="index"+".html";

                String reportPath = Constants.REPORTS_PATH + fileName;
                extent = new ExtentReports(reportPath, true, DisplayOrder.NEWEST_FIRST);
                extent.loadConfig(new File(System.getProperty("user.dir") + "/config/ReportsConfig.xml"));
                // optional
                extent.addSystemInfo("Selenium Version", "2.53.0").addSystemInfo(
                        "Environment", Constants.ENV).addSystemInfo("Qa","Shiva");
            }
            return extent;
        }
    }

1 个答案:

答案 0 :(得分:0)

这可以通过javascript完成。使用<scripts>标签添加以下脚本

$(document).ready(function() {
    var imageElements = $('img.r-img');
    for (var i=0; i<imageElements.length; i++) {
        imageElements[i].setAttribute('style', 'width:25%;');
    }
});

您可以根据需要设置屏幕截图(img元素)的样式。