【发布时间】:2017-06-04 05:39:26
【问题描述】:
运行时,java抛出以下异常: 线程“主”org.openqa.selenium.SessionNotCreatedException 中的异常:无法创建新的远程会话。所需功能 = 功能 [{marionette=true, browserName=firefox, version=, platform=A。 我正在使用 gecko 驱动程序 16.1。当我使用 gecko 14.01 时,它会导航到 gmail 页面,然后即使我设置了隐式等待也无法找到元素。
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.MarionetteDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class login {
public static void main(String[] args) {
// Create a new instance of the Firefox driver
System.setProperty("webdriver.gecko.driver","C:/Users/asdf/Desktop/selenium/gecko32/geckodriver.exe");
DesiredCapabilities capabilities=DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
WebDriver driver = new MarionetteDriver(capabilities);
//WebDriver driver = new FirefoxDriver();
// Wait For Page To Load
// Put a Implicit wait, this means that any search for elements on the page
driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
// Navigate to URL
driver.get("https://mail.google.com/");
driver.manage().window().maximize();
//driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
// gmail login
driver.findElement(By.xpath("//*[@id='identifierId']")).sendKeys("username");
driver.findElement(By.id("next")).click();
driver.findElement(By.id("Passwd")).sendKeys("password");
【问题讨论】: