Java 引诱报告:Chrome 中未显示任何内容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23997449/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Allure report: nothing shown in Chrome
提问by just-boris
I'm trying to use Allure-frameworkto generate a report for my Selenium WebDrivertests. I use JUnit
framework and allure-maven-pluginwith version 1.3.9 of Allure. I run tests with mvn test
then generate the report using mvn site
. I see generated report in target/site/allure-maven-plugin/
directory. When I open index.htmlpage with Firefox it works normally. However when doing the same thing in Chrome or Safari I see nothing.
我正在尝试使用Allure-framework为我的Selenium WebDriver测试生成报告。我将JUnit
框架和allure-maven-plugin与 Allure 的 1.3.9 版一起使用。我运行测试mvn test
然后使用生成报告mvn site
。我在target/site/allure-maven-plugin/
目录中看到生成的报告。当我用 Firefox打开index.html页面时,它可以正常工作。然而,当在 Chrome 或 Safari 中做同样的事情时,我什么也没看到。
What's wrong? Am I missing something? My pom.xml
file is located here.
怎么了?我错过了什么吗?我的pom.xml
文件位于此处。
采纳答案by vania-pooh
This problem is related to default Webkit security settings which forbid doing Ajax requests on the local filesystem. You have at least two possible solutions:
此问题与默认 Webkit 安全设置有关,该设置禁止在本地文件系统上执行 Ajax 请求。您至少有两种可能的解决方案:
- Serve index.htmlwith some web-server like Nginx or Apache. This will emulate remote website and thus trick your browser. With Allure CLI 2.0+ this can be done using the following command:
- 即成的index.html与像Nginx的或Apache一些Web服务器。这将模拟远程网站,从而欺骗您的浏览器。使用 Allure CLI 2.0+,这可以使用以下命令完成:
$ allure report open
$诱惑报告打开
- Use --allow-file-access-from-filesChrome flag. See details in this question.
- 使用--allow-file-access-from-filesChrome 标志。请参阅此问题中的详细信息。
回答by JavaCreeper
In Addition to the above answer using "--ignore-certifcate-errors" with chromeOptions might be helpfull.
除了使用带有 chromeOptions 的“--ignore-certifcate-errors”的上述答案可能会有所帮助。
DesiredCapabilities capabilities;
capabilities = DesiredCapabilities.chrome();
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--ignore-certifcate-errors");
chromeOptions.addArguments("test-type");
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
WebDriver driver = new ChromeDriver(capabilities);
回答by sahlouls
To use allure report in chrome, you have two options:
要在 chrome 中使用诱惑报告,您有两个选择:
- Use
mvn allure:serve
target. It will generate the report and open a tab in Chrome (if default browser) - Generate the report using
mvn allure:report
target and serve the site your self, using any http server. if you have node you can usehttp-server
for examplenpm install http-server -g
and thenhttp-server target/site/allure-maven-plugin
)
- 使用
mvn allure:serve
目标。它将生成报告并在 Chrome 中打开一个选项卡(如果是默认浏览器) - 使用
mvn allure:report
目标生成报告并使用任何 http 服务器为您自己的站点提供服务。如果你有节点,你可以使用http-server
例如npm install http-server -g
然后http-server target/site/allure-maven-plugin
)
DO NOT use --allow-file-access-from-files
flag, is it DANDEGEROUS
不要使用--allow-file-access-from-files
标志,它是危险的