web-dev-qa-db-ja.com

org.openqa.Selenium.SessionNotCreatedException:新しいセッションを作成できませんでした。 (元のエラー:新しいセッションを要求しましたが、1つは進行中でした)

IOS用のAppium1.4.8を使用しています。 xcodeを使用してシミュレーターでコードをビルドし、サーバーとAppiumInspectorを正常に起動できました。しかし、私のコードを実行している間、それは以下のエラーをスローしています。

私の機能は@BeforeMethodです。publicvoidsetUp()throws MalformedURLException {

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("appium-version", "1.0");
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "8.4");
capabilities.setCapability("deviceName", "iPad 2");
capabilities.setCapability("app", "/Users/arunhs/Desktop/AppiumReq/SRC/build/Debug-iphonesimulator/ComplianceWire.app");
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

}

Error is: 
FAILED CONFIGURATION: @BeforeMethod setUp
org.openqa.Selenium.SessionNotCreatedException: A new session could not be created. (Original error: Requested a new session but one was in progress) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 447 milliseconds
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: Host: 'N/A', ip: 'N/A', os.name: 'Mac OS X', os.Arch: 'x86_64', os.version: '10.10.4', Java.version: '1.7.0_79'
Driver info: io.appium.Java_client.AppiumDriver
at Sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at Sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.Java:57)
at Sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.Java:45)
at Java.lang.reflect.Constructor.newInstance(Constructor.Java:526)
at org.openqa.Selenium.remote.ErrorHandler.createThrowable(ErrorHandler.Java:206)
at org.openqa.Selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.Java:158)
at org.openqa.Selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.Java:595)
at io.appium.Java_client.AppiumDriver.execute(AppiumDriver.Java:88)
at org.openqa.Selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.Java:242)
at org.openqa.Selenium.remote.RemoteWebDriver.(RemoteWebDriver.Java:128)
at org.openqa.Selenium.remote.RemoteWebDriver.(RemoteWebDriver.Java:155)
at io.appium.Java_client.AppiumDriver.(AppiumDriver.Java:44)
at com.Selenium.test.DriverScript.setUp(DriverScript.Java:68)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:57)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:606)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.Java:85)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.Java:515)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.Java:213)
at org.testng.internal.Invoker.invokeMethod(Invoker.Java:590)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.Java:834)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.Java:1142)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.Java:124)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.Java:108)
at org.testng.TestRunner.privateRun(TestRunner.Java:771)
at org.testng.TestRunner.run(TestRunner.Java:621)
at org.testng.SuiteRunner.runTest(SuiteRunner.Java:357)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.Java:352)
at org.testng.SuiteRunner.privateRun(SuiteRunner.Java:310)
at org.testng.SuiteRunner.run(SuiteRunner.Java:259)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.Java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.Java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.Java:1176)
at org.testng.TestNG.runSuitesLocally(TestNG.Java:1101)
at org.testng.TestNG.run(TestNG.Java:1009)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.Java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.Java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.Java:175)
4
amitav

これは、前のセッションが適切にシャットダウンされなかったために発生し、テストで例外がスローされたときに発生します。 appiumサーバーを再起動して試してみると、問題が解決するはずです。

あるいは、ノードプロセスとしてappiumを開始する場合は、オプション'--session-override true'を指定できます。これにより、この問題を回避できます。

6
Sham332

以下は私のために働いています。 Androidデバイスを接続してテストしています。必要に応じて変更を加えて適用してください。これで、動作するはずです。

        DesiredCapabilities capabilities = new DesiredCapabilities().Android();
        capabilities.setCapability("no",true);
        capabilities.setCapability("newCommandTimeout", 100000);
        capabilities.setCapability("noReset", true);
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        capabilities.setCapability(CapabilityType.VERSION, "4.4.2");
        capabilities.setCapability("deviceName", "Galaxy nexus");
        capabilities.setCapability("app", application.getAbsolutePath());
        capabilities.setCapability("automationName", "selendroid");
        capabilities.setCapability("noRest", true);
        driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
3
CodeFlash

機能にdeviceNameを追加すると役立ちました。 appiumログで、私は足りないものを見つけることができました。

1
Gloria Rampur

Appiumアプリの場合は、[設定]の下の[Override Existing Sessions]チェックボックスを選択します-

enter image description here

1
Tarun