Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Host info: host: 'XXXXX', ip: 'XXXXX'
Build info: version: '4.26.0', revision: '69f9e5e'
System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '23.0.1'
Driver info: io.appium.java_client.android.AndroidDriver
Command: [null, newSession {capabilities=[Capabilities {app: C:UsersxxxxxxOneDriveDoc..., appActivity: app.superssmart.ui.MainActi..., appPackage: app.superssmart, browserName: , deviceName: emulator-5554, noReset: true, platformName: ANDROID}]}]
Capabilities {app: C:UsersxxxxOneDriveDoc..., appActivity: app.superssmart.ui.MainActi..., appPackage: app.superssmart, browserName: , deviceName: emulator-5554, noReset: true, platformName: ANDROID}
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:563)
at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:270)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:174)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:91)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:103)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:109)
at appium.test.App_Main.main(App_Main.java:29)
Caused by: java.lang.IllegalArgumentException: Illegal key values seen in w3c capabilities: [app, appActivity, appPackage, deviceName, noReset]
at org.openqa.selenium.remote.NewSessionPayload.lambda$validate$5(NewSessionPayload.java:163)
at java.base/java.util.stream.ReferencePipeline$15$1.accept(ReferencePipeline.java:580)
at java.base/java.util.stream.ReferencePipeline$15$1.accept(ReferencePipeline.java:581)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:215)
at java.base/java.util.stream.ReferencePipeline$15$1.accept(ReferencePipeline.java:581)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1709)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:570)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:560)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:636)
at org.openqa.selenium.remote.NewSessionPayload.validate(NewSessionPayload.java:167)
at org.openqa.selenium.remote.NewSessionPayload.<init>(NewSessionPayload.java:70)
at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:99)
at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:84)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:60)
at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:176)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:237)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
... 6 more
Code:
public static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException, InterruptedException {
File appDir = new File("C:\Users\keert\OneDrive\Documents\App");
File app=new File(appDir,"app.apk");
DesiredCapabilities cap=new DesiredCapabilities();
cap.setCapability(CapabilityType.BROWSER_NAME, "");
cap.setCapability("platformName", "Android");
cap.setCapability("app", app.getAbsolutePath());
cap.setCapability("deviceName", "emulator-5554");
cap.setCapability("appPackage", "app.superssmart");
cap.setCapability("appActivity", "app.superssmart.ui.MainActivity");
cap.setCapability("noReset", true);
driver=new AndroidDriver(new URL("http://127.0.0.1:4723/"),cap);
Source: Read More