Facing issue while launching chrome browser Appium. Chrome browser is getting opened multiple times(4 times) and closing even if a single @test method is present. After browser launch url is not getting entered.
Testing Environment: Nexus 5, Andriod 5.1.1, Chrome 54(latest), Appium latest (AppiumForWindows_1_4_16_1).
Selenium Code:
package com.cxm.testcases;
import java.net.MalformedURLException;
import java.net.URL;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
public class Appium
{
@Test
public void test1() throws MalformedURLException, InterruptedException{
// Create object of DesiredCapabilities class and specify android platform
DesiredCapabilities capabilities=DesiredCapabilities.android();
// set the capability to execute test in chrome browser
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME,BrowserType.CHROME);
// set the capability to execute our test in Android Platform
capabilities.setCapability(MobileCapabilityType.PLATFORM,Platform.ANDROID);
// we need to define platform name
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,"Android");
capabilities.setCapability("appium-version", "1.4.16.1");
// Set the device name as well (you can give any name)
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"Nexus5");
// set the android version as well
capabilities.setCapability(MobileCapabilityType.VERSION,"5.1.1");
// Create object of URL class and specify the appium server address
URL url= new URL("http://127.0.0.1:4723/wd/hub");
// Create object of AndroidDriver class and pass the url and capability that we created
WebDriver driver = new AndroidDriver(url, capabilities);
System.out.println("before entring url");
// Open url
driver.get("http://www.google.com");
// print the title
System.out.println("Title "+driver.getTitle());
// enter username
driver.findElement(By.name("email")).sendKeys("abc");
// enter password
driver.findElement(By.name("pass")).sendKeys("sel");
// click on submit button
driver.findElement(By.id("u_0_5")).click();
// close the browser
driver.quit();
}
}
Console Error:
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: A new session could not be created. (Original error: session not created exception from unknown error: Runtime.executionContextCreated has invalid ‘context’: {“auxData”:{“frameId”:“1213.1”,“isDefault”:true},“id”:1,“name”:"",“origin”:"://"} (Session info: chrome=54.0.2840.85) (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 6.1 SP1 x86))) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds Build info: version: ‘3.0.1’, revision: ‘1969d75’, time: ‘2016-10-18 09:49:13 -0700’ System info: host: ‘CSSLSYSTEM-283’, ip: ‘172.30.5.86’, os.name: ‘Windows 7’, os.arch: ‘x86’, os.version: ‘6.1’, java.version: ‘1.8.0_60’ Driver info: driver.version: AndroidDriver at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:161) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:64) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601) at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241) 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:109) at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:39) at com.cxm.testcases.Appium.test1(Appium.java:45) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80) at org.testng.internal.Invoker.invokeMethod(Invoker.java:714) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198) at org.testng.TestNG.runSuitesLocally(TestNG.java:1123) at org.testng.TestNG.run(TestNG.java:1031) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:152) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:57)