我的项目在另一台PC上运行良好。但是我使用导入现有的maven项目将其导入到另一台PC中。
在新的PC设置中,我有以下设置:
Project -> properties -> java compiler version -> set to 1.8
Project -> project facets -> java version -> set to 1.8
Run Code Online (Sandbox Code Playgroud)
表明 JRE System Library [javaSE-1.8]
pom.xml具有<java-version>1.8</java-version>
以下maven插件:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
使用上面的设置(如果我运行),clean install则控制台错误如下:
2018-05-18 10:07:56.255 INFO 5644 --- [ main] com.dvl.AssetTrackerApplication : Starting AssetTrackerApplication on DESKTOP-M0588P2 with PID 5644 (started by Dhaval in E:\STS Workspace\AssetTracker)
2018-05-18 10:07:56.255 INFO 5644 --- [ main] com.dvl.AssetTrackerApplication : No active …Run Code Online (Sandbox Code Playgroud) 我正在写一个简单的硒测试,我需要截取网页截图并将其保存为PDF.我正在使用带有Selenium的TestNG和PDFbox库
以下是我的测试方法:
package com.helper;
import java.io.File;
import java.io.IOException;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.testng.annotations.Test;
public class ScreenshotPDF {
@Test
public void screenshotPDF(){
WebDriver driver= DriverManager.getWebdriver("chrome");
driver.get("https://www.google.co.in");
try {
File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
PDDocument document = new PDDocument();
PDPage page = new PDPage();
document.addPage(page);
PDImageXObject pdi = PDImageXObject.createFromFileByContent(screenshot ,document);
PDPageContentStream contentStream = new PDPageContentStream(document, page);
contentStream.drawImage(pdi,100,100);
document.save("C:/Users/123456/Documents/sample.pdf");
contentStream.close();
document.close();
} catch (WebDriverException e) {
e.printStackTrace();
} catch (IOException e) …Run Code Online (Sandbox Code Playgroud)