[英]SeleniumError : org.openqa.selenium.SessionNotCreatedException
On doing a driver.close();driver.quit();
在执行
driver.close();driver.quit();
during the execution of java code, the following error is thrown: 在执行Java代码期间,将引发以下错误:
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Tried to run command without establishing a connection Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:26.402Z' System info: host: 'ADMIN-PC', ip: '192.168.1.6', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_151' Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{moz:profile=C:\\Users\\admin\\AppData\\Local\\Temp\\rust_mozprofile.ENTBvl2aDbSs, rotatable=false, timeouts={implicit=0, pageLoad=300000, script=30000}, pageLoadStrategy=normal, moz:headless=false, platform=XP, specificationLevel=0, moz:accessibilityChecks=false, acceptInsecureCerts=true, browserVersion=56.0.2, platformVersion=10.0, moz:processID=5004, browserName=firefox, javascriptEnabled=true, platformName=XP}] Session ID: 82e7dabd-c178-4d90-a3f8-84dc3f6ff14f at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl
线程“主”中的异常org.openqa.selenium.SessionNotCreatedException:尝试在不建立连接的情况下运行命令构建信息:版本:'3.6.0',修订版:'6fbf3ec767',时间:'2017-09-27T16:15: 26.402Z'系统信息:主机:'ADMIN-PC',ip:'192.168.1.6',操作系统名称:'Windows 10',os.arch:'x86',os.version:'10 .0',java.version :“ 1.8.0_151”驱动程序信息:org.openqa.selenium.firefox.FirefoxDriver功能[{moz:profile = C:\\ Users \\ admin \\ AppData \\ Local \\ Temp \\ rust_mozprofile.ENTBvl2aDbSs,rotatable = false,超时= {隐式= 0,pageLoad = 300000,脚本= 30000},pageLoadStrategy = normal,moz:headless = false,平台= XP,specificationLevel = 0,moz:accessibilityChecks = false,acceptInsecureCerts = true,browserVersion = 56.0.2,platformVersion = 10.0, moz:processID = 5004,browserName = firefox,javascriptEnabled = true,platformName = XP}]会话ID:位于sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native方法)处的sun.reflect.NativeConstructorAccessorImpl处的82e7dabd-c178-4d90-a3f8-84dc3f6ff14f .newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:185) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:643) at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:482) at yahoo.main(yahoo.java:34)
org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java上的sun.reflect.DelegatingConstructorAccessorImpl.newInstance(未知源)在java.lang.reflect.Constructor.newInstance(未知源) :185),位于org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120),位于org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodea.open org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)上的selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoWeb。 yahoo.main(yahoo.java)上org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:482)上org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:643)上的java:586) :34)
Sharing code that throws the above exception : 共享引发上述异常的代码:
//package basicSeleniumScripts;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class yahoo {
public static void main(String[] args) {
String Firefoxdriverpath = "C:\\Marionette\\geckodriver_1.exe";
WebDriver driver;
System.setProperty("webdriver.gecko.driver",Firefoxdriverpath);
//create a new instance of Firefox driver
driver = new FirefoxDriver();
//Open the page we want to open
driver.get("http://www.yahoo.com");
//Defining expected title
String expectedTitle = "Yahoo";
//Getting the actual title
String actualTitle = null;
actualTitle = driver.getTitle();
//Validating the TestCase
if (actualTitle.contentEquals(expectedTitle))
{
System.out.println("Test Passed");
}
else
{
System.out.println("Test Failed!!!");
}
driver.close();
driver.quit();
}
}
Update the gecko driver version to v0.19.0 as you are using 3.6.0 jars of selenium. 使用3.6.0罐硒时,将gecko驱动程序版本更新为v0.19.0。
Also use quit method only 也只能使用退出方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.