我已经使用Maven设置了Eclipse,并创建了一个添加Selenium和TestNG依赖项的项目。我现在正在尝试在Chrome中运行我的测试,我知道我可以设置System.setProperty("webdriver.chrome.driver","C:\\path-to\\chromedriver.exe");
,但我也看到某个地方可以在运行配置中建立chromedriver的路径,从而避免添加配置行代码。
这是我测试中的代码:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class Demo {
@Test
public void demoTest(){
WebDriver driver=new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://www.google.com");
driver.quit();
}
}
但是在将项目作为“Maven测试”运行后,我得到了这个并且没有任何反应(Chrome未打开):
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building project-name 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ project-name ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ project-name ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ project-name ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ project-name ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ project-name ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.737 s
[INFO] Finished at: 2017-07-01T08:36:03-03:00
[INFO] Final Memory: 11M/245M
[INFO] ------------------------------------------------------------------------
我错过了什么?
答案 0 :(得分:1)
你可以尝试作为JUNIT运行并在DEBUG模式下运行,这样你就会发现确切的错误我认为首先没有选择测试类,
在DEBUG模式下运行JUNIT并调试代码..希望这对你有帮助。