我将 Selenium WebDriver 3.0 和 AppliToolsEyes 2.54 用于 selenium-java
<dependency>
<groupId>com.applitools</groupId>
<artifactId>eyes-selenium-java</artifactId>
<version>2.54</version>
</dependency>
对于视觉测试,编写了以下代码 -
private WebDriver driver;
private Eyes eyes;
private static final String url = "http://www.google.com";
@BeforeClass
public void setUp(){
eyes = new Eyes();
System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir") + "//src//test//resources//geckodriver.exe");
driver = new FirefoxDriver();
driver.manage().window().maximize();
}
@AfterClass
public void tearDown(){
eyes.abortIfNotClosed();
driver.quit();
}
@Test
public void visualTest(){
eyes.checkWindow();
driver.get(url);
eyes.checkWindow();
eyes.close();
}
但是在运行代码时出现以下错误eyes.checkWindow()
java.lang.IllegalStateException: Eyes not open
at com.applitools.utils.ArgumentGuard.isValidState(ArgumentGuard.java:117)
at com.applitools.eyes.EyesBase.checkWindowBase(EyesBase.java:977)
at com.applitools.eyes.Eyes.checkWindow(Eyes.java:359)
at com.applitools.eyes.Eyes.checkWindow(Eyes.java:335)
at com.applitools.eyes.Eyes.checkWindow(Eyes.java:325)