public class SeleniumExample {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
System.err.println("Driver");
driver.get("http://www.google.com");
System.err.println("Driver get");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("Cheese!");
element.submit();
System.out.println("Page title is: " + driver.getTitle());
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("cheese!");
}
});
// Should see: "cheese! - Google Search"
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
}
}
我是Selenium的新手......我不知道为什么我得到这个例外....我有最新的50.1.0与最新的firefox selenium驱动程序3.0.1,我不知道为什么我得到这个错误消息:
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/NoSuchSessionException
at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:277)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:247)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:242)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:238)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:127)
at SeleniumExample.main(SeleniumExample.java:13)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.NoSuchSessionException
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)
感谢您的帮助!
答案 0 :(得分:0)
我必须在<li *ngFor="let child of children">
<a (click)="navChanged(child.name)" [ngClass]="{'active' : child.name === selected}">
<div> {{child.name}} </div>
</a>
</li>
geckodriver
使用Firefox
,如下所示:
selenium 3.0