Extent Report需要在线加载css,不然生成的html report会很难看。

但可以设置不在线加载css,而是使用本地css,在使用htmlreporter加上这句

htmlReporter.config().setResourceCDN(ResourceCDN.EXTENTREPORTS);

以下是调试通过的代码
package com.qa.reports;

import java.text.SimpleDateFormat;
import java.util.Date; import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver; import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.ResourceCDN;
import com.aventstack.extentreports.Status;
import com.aventstack.extentreports.reporter.ExtentHtmlReporter; public class ExtentReporter { static WebDriver driver=null; public static void main(String[]args) throws InterruptedException { String userDir=System.getProperty("user.dir");
System.out.println("User Dir=:"+userDir); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd-HHmmss");// 设置日期格式
System.out.println(df.format(new Date()));// new Date()为获取当前系统时间 String datetime=df.format(new Date()); ExtentHtmlReporter html = new ExtentHtmlReporter(userDir+"\\test-output\\Extent"+datetime+".html");
html.config().setResourceCDN(ResourceCDN.EXTENTREPORTS);
ExtentReports extent=new ExtentReports();
extent.attachReporter(html); ExtentTest test = extent.createTest("Navigate to Baidu Home Page."); System.setProperty("webdriver.gecko.driver","C:\\eclipse-workspace\\SeleniumTestNG\\Drivers\\geockdriver\\geckodriver.exe");
driver=new FirefoxDriver(); test.log(Status.INFO, "Start Testing.");
driver.get("http://www.baidu.com");
String title=driver.getTitle();
test.pass("Get title passed.");
Thread.sleep(2000); test.log(Status.INFO, "Start searching Weather.");
driver.findElement(By.id("kw")).sendKeys("天气");
driver.findElement(By.id("su")).click();
Thread.sleep(2000);
test.pass("Search Weather passed.");
extent.flush(); driver.close();
driver.quit();
//test.pass("Tests passed, close the browser."); //extent.flush();
//extent.
}
}

参考链接:

https://www.cnblogs.com/lozz/p/7308093.html

https://www.jianshu.com/p/f34736f5b402

 

Selenium Extent Report的设置的更多相关文章

  1. Selenium生成Report的利器- ExtentReports

    生成的报告最后的样子是: 里面加了截图, 将每一步骤的截图,(所以方法里多加了一个截屏方法). 加入到报告中,这样更清晰明了.首先 pom文件中需引用:<!-- 报告输出 --><d ...

  2. selenium webdriver(5)---超时设置

    自动化测试中,等待时间的运用占据了举足轻重的地位,平常我们需要处理很多和时间息息相关的场景,例如: 打开新页面,只要特定元素出现而不用等待页面全部加载完成就对其进行操作 设置等待某元素出现的时间,超时 ...

  3. Selenium webdriver firefox 路径设置问题

    问题: Cannot find firefox binary in PATH. Make sure firefox is installed. 原因:selenium找不到Firefox浏览器. 方法 ...

  4. Selenium之PhantomJS相关设置

    设置PhantomJS请求头 默认情况下: from selenium import webdriver import time driver = webdriver.PhantomJS() driv ...

  5. Selenium启动项参数设置

    再Selenium中使用不同的Webdriver可能会有不一样的方法,有些相同的操作会得到不同的结果, 本文主要介绍的是Chrome()的使用方法. 其他的Webdriver可以参考官方文档 Chro ...

  6. Cognos11中通过URL访问report的设置

    1:以往的cognos版本中在报表的属性中可以找到 url的属性,稍加修改就可以通过URL进行访问了 2:Cognos11中找了半天也没有报表URL这个属性,但是IBM官方也给出了解决方案 Answe ...

  7. centos 无界面安装selenium+chrome+chromedirver的设置

    配了一中午的,好不容易正好记录下. 1.我的centos的位数 输入rpm -q centos-release 结果:centos-release-7-4.1708.el7.centos.x86_64 ...

  8. selenium,html高宽设置成了0,会影响元素可见性,怎么手动修改某个元素的高宽?

     问题:要js的话,需要用webelment,此时元素已经是不可见了   ((JavascriptExecutor) this.driver).executeScript("argument ...

  9. robotframe中使用report,设置路径带有时间戳

    1.打开C:\Python27\Lib\site-packages\robotide\contrib\testrunner,找到testrunner.py.   修改代码块def _create_te ...

随机推荐

  1. JSP——文件上传

    Web应用中,文件的上传是很常见的功能,今天在此记录下所学的感悟吧. 实现Web应用中文件的上传需要用到的核心组件是Commen-fileUpload,组件, 但还需要Common-IO组件的支持.可 ...

  2. windows2008 apache2.4 tomcat-7多域名绑定环境配置

    =====================软件清单Apache2.4.33apache-tomcat-7.0.85===================== 1.安装apache    1.1下载ap ...

  3. [php]php设计模式 (总结)

    转载自[php]php设计模式 (总结) 传统的23种模式(没有区分简单工厂与抽象工厂) http://www.cnblogs.com/bluefrog/archive/2011/01/04/1925 ...

  4. python爬百度文库课件

    库:re;selenium;requests 源码: from selenium import webdriverimport reimport requests def open_img(items ...

  5. java-设计模式-索引

    设计模式的七大原则 设计模式遵循的七大原则 微信红包的设计实践 单例模式 常见的几种单例模式写法 单例模式的应用场景及优缺点 面向对象六大设计原则 JAVA设计模式之观察者模式 JAVA设计模式之策略 ...

  6. scrapy爬去京东书籍信息

    # -*- coding: utf-8 -*- import scrapy import urllib import json from copy import deepcopy class JdSp ...

  7. 搭建IntelliJ IDEA授权服务器

    地址:https://blog.csdn.net/maozexijr/article/details/79072287    https://www.jianshu.com/p/754d8f907f2 ...

  8. 浅谈Android之Activity生命周期

     Activity作为四大组件之一,出现的频率相当高,基本上我们在android的各个地方都能看见它的踪影,因此深入了解Activity,对于开发高质量应用程序是很有帮助的.今天我们就来详细地聊聊Ac ...

  9. 关于 someone could be eavesdropping on you right now (man-in-the-middle attack) ssh的解决办法

    记录工作中遇到的问题 someone could be eavesdropping on you right now (man-in-the-middle attack) ssh 由于远程机器或者重组 ...

  10. orcal - 伪列

    数据伪劣 行号 ROWNUM SELECT ROWNUM, empno,ename,sal from emp; 取出第一行数据 SELECT ROWNUM, empno,ename,sal from ...