appium / java-client

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol
Apache License 2.0
1.22k stars 758 forks source link

SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. #1941

Open SolSpatial opened 1 year ago

SolSpatial commented 1 year ago

Description

Hi everyone, i'm getting 'SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Host info: host: 'localhost', ip: '127.0.0.1' cuando quiero conectarme al servidor de appium local desde android studio(kotlin).

Environment

Below is my Environment: Mac OS: Ventura 13.4 Android Studio: 2022.1.1 Appium.io : 8.5.1 Appium server: 2.0.0-beta.71 node: v20.3.0 device: Android Samsung A235M

Code To Reproduce Issue

`@get:Rule val activityScenarioRule = ActivityScenarioRule(LaunchActivity::class.java)

private lateinit var driver: AndroidDriver

@Before
@Throws(MalformedURLException::class)
fun setUp() {
    val desiredCapabilities = DesiredCapabilities()
    desiredCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "samsung SM-A235M")
    desiredCapabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "13")
    desiredCapabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "android")
    desiredCapabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "appium")
    //desiredCapabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome")
    val remoteUrl = URL("http://127.0.0.1:4723")
    driver = AndroidDriver(remoteUrl, desiredCapabilities)
}

@After
fun tearDown() {
    driver?.quit()
}

@Test
fun testButtonNavigationToBrowser() {
    onView(withId(R.id.single_single_on_btn)).perform(click())

    Thread.sleep(7000)

    val inputField = driver?.let {
        it.findElement(By.cssSelector("input[name='domain']"))
    }

    inputField?.let { it.sendKeys("fulcrum") }
}`

Link To Appium Logs

' 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: 'localhost', ip: '127.0.0.1' at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:561) at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:274) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:157) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:89) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:101) at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:113) at com.spatialnetworks.fulcrum.app.LoginDomainTest.setUp(LoginDomainTest.kt:38) ... 33 trimmed Caused by: org.openqa.selenium.WebDriverException: Connection refused Build info: version: '4.9.1', revision: 'eb2032df7f' System info: os.name: 'Linux', os.arch: 'aarch64', os.version: '4.19.157-perf-25521380-abA235MUBU1BVL1', java.version: '0' Driver info: driver.version: AndroidDriver at io.appium.java_client.remote.AppiumCommandExecutor.lambda$execute$4(AppiumCommandExecutor.java:262) at io.appium.java_client.remote.AppiumCommandExecutor$$ExternalSyntheticLambda3.get(Unknown Source:2) at java.util.Optional.orElseGet(Optional.java:365) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:261) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543) ... 40 more Caused by: java.net.ConnectException: Connection refused at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:762) at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:337) at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:776) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:1012)'