我刚开始学习 Selenium
Java
。我正在使用 Selenium Beta 3
和 Mozilla Firefox v43
运行我的脚本。以下是我的代码:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class RegistrationFirefox {
public static void main(String[] args)
{
System.setProperty("webdriver.gecko.driver", "C:\\SeleniumDrivers\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
System.out.println(driver.getTitle());
driver.manage().window().maximize();
driver.close();
}
}
最初,我遇到了以下错误:
"Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver
在安装了geckodriver
之后,我遇到了以下错误(上面提到的代码):
请注意,在翻译过程中保留了HTML标签。Exception in thread "main" org.openqa.selenium.WebDriverException: Unsupported Marionette protocol version 2, required 3 (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 5.26 seconds