您必须在代码中考虑几个因素,如下所示:
在提及时,System.setProperty
您需要提供 的绝对路径,如下所示:
System.setProperty("webdriver.gecko.driver", "C:\\your_directory\\geckodriver.exe");
一旦提及ImplicitlyWait
,它将在程序执行期间保留下来。您可以考虑删除多个提及。
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
package demo;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class Q44308973_remote_unreachablebrowserexception {
public static void main(String[] args)
{
System.setProperty("webdriver.gecko.driver", "C:\\your_directory\\geckodriver.exe");
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(dc);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://google.com");
}
}