等待用于synchronizing asynchronous operations
. 所以我试图将它用于我的自动化项目来处理同步问题。所以我尝试了一些基本的程序。
import static org.awaitility.Awaitility.*;
import static org.awaitility.Duration.*;
import static java.util.concurrent.TimeUnit.*;
import static org.hamcrest.Matchers.*;
import java.util.concurrent.TimeUnit;
public static void main( String[] args )
{
System.setProperty("webdriver.chrome.driver", "C:/Learning/synchronization/Resources/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://www.seleniumeasy.com/test/dynamic-data-loading-demo.html");
WebElement newUserBtn = driver.findElement(By.id("save"));
WebElement loadingElement = driver.findElement(By.id("loading"));
// Get a new User
newUserBtn.click();
await().atMost(15,TimeUnit.SECONDS).until(loadingElement::getText, not("Loading..."));
System.out.println("User profile retrieved");
}
但是每当它遇到下面的行时,它就会抛出下面的异常
await().atMost(15,TimeUnit.SECONDS).until(loadingElement::getText, not("Loading..."));
错误信息:
Exception in thread "main" java.lang.NoClassDefFoundError: org/awaitility/Awaitility
at com.testing.automation.synchronization.App.main(App.java:35)
Caused by: java.lang.ClassNotFoundException: org.awaitility.Awaitility
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
我想到是否遗漏了任何依赖项,从而导致以下错误。但我不确定。我正在使用 Java 8 版本的 Maven 项目。
<dependencies>
<!-- https://mvnrepository.com/artifact/org.awaitility/awaitility -->
<!-- https://mvnrepository.com/artifact/org.awaitility/awaitility -->
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>3.1.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.awaitility/awaitility-proxy -->
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility-proxy</artifactId>
<version>3.1.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
我真的不知道为什么我会收到这个错误。
有人可以帮我解决这个问题吗?