当前位置: 首页 > 知识库问答 >
问题:

尝试在Android上打开google chrome浏览器时出现“无法启动Appium会话,错误为:Error:spawn enoint”错误消息

晁绍辉
2023-03-14

我写了一个简单的代码,只需在Android上打开google chrome浏览器即可启动网络url并关闭浏览器,以下是我的代码:

package com.roofandfloor.initial;

import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;

public class SampleCode {

    public static void main(String[] args) throws MalformedURLException {
        DesiredCapabilities capabilities = DesiredCapabilities.android();
        capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, BrowserType.CHROME);
        capabilities.setCapability(MobileCapabilityType.PLATFORM, Platform.ANDROID);
        capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
        capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Micromax");
        capabilities.setCapability(MobileCapabilityType.VERSION, "5.0");
        URL url = new URL("http://127.0.0.1:4723/wd/hub");
        WebDriver driver = new AndroidDriver<>(url,capabilities);
        driver.get("https://www.facebook.com");
        driver.quit();

    }

}

I am getting an error at the line "WebDriver driver = new AndroidDriver<>(url,capabilities);"

below is the logs from APPIUM:

> info: --> POST /wd/hub/session {"desiredCapabilities":{"browserName":"chrome","platformName":"Android","version":"5.0","deviceName":"Micromax","platform":"ANDROID"}}
> info: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.8.0_131)
> info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : version, platform
> info: Set mode: Proxying straight through to Chromedriver
> info: [debug] Looks like we want chrome on android
> info: [debug] Creating new appium session 4af282c8-e0e4-45c3-873c-3d10ccfc5229
> info: [debug] Checking whether adb is present
> warn: The ANDROID_HOME environment variable is not set to the Android SDK root directory path. ANDROID_HOME is required for compatibility with SDK 23+. Checking along PATH for adb.
> info: [debug] executing cmd: where adb
> info: [debug] Using adb from C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe
> 
> info: [debug] Using fast reset? true
> info: [debug] Preparing device for session
> info: [debug] Not checking whether app is present since we are assuming it's already on the device
> info: Retrieving device
> info: [debug] Trying to find a connected android device
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: "C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe" devices
> info: [debug] 1 device(s) connected
> info: Found device 0123456789ABCDEF
> info: [debug] Setting device id to 0123456789ABCDEF
> info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
> info: [debug] executing cmd: "C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe" -s 0123456789ABCDEF wait-for-device
> info: [debug] executing cmd: "C:\Users\admin\AppData\Local\Android\android-sdk\platform-tools\adb.exe" -s 0123456789ABCDEF shell "echo 'ready'"
> info: [debug] Starting logcat capture
> error: Logcat capture failed: spawn ENOENT
> info: [debug] Cleaning up appium session
> error: Failed to start an Appium session, err was: Error: spawn ENOENT
> info: [debug] Error: spawn ENOENT
>     at errnoException (child_process.js:988:11)
>     at Process.ChildProcess._handle.onexit (child_process.js:779:34)
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: spawn ENOENT)","code":"ENOENT","errno":"ENOENT","syscall":"spawn","origValue":"spawn ENOENT"},"sessionId":null}
> info: <-- POST /wd/hub/session 500 6536.205 ms - 197 

在Eclipse上,我遇到了以下错误:

线程“main”中的异常org.openqa.selenium.SessionNotCreatedException:无法创建新会话。(原始错误:spawn ENOENT)

我无法理解为什么会出现上述错误消息。

下面是我正在使用的软件版本

Selenium Server Sstandalone: 2.53.1
Java Client for Appium 4.1.2
Appium Version: 1.4.13.1

请帮忙解决这个问题,我对APPIUM很陌生。

共有1个答案

韩景胜
2023-03-14

升级Appium Server 1.6.4后,问题得到解决。

 类似资料:
  • 问题内容: 我刚接触selenium。我生成了我的第一个Javaselenium测试用例,它已成功编译。但是当我运行该测试时,我得到了以下RuntimeException 请告诉我如何解决此错误。 这是我要运行的Java文件。 我首先通过命令提示符启动了selenium服务器,然后通过另一个命令提示符执行了上述java文件。 第二个问题:我可以右键单击包含selenium的网页上的指定位置。 问题

  • 嘿,伙计们,所以我基本上已经做了需要做的事情,使appium上升和运行。安装JDK1.8(最新版本),安装Android SDK,更新环境变量,安装Appium1.4(最新版本),安装Eclipse,并在将手机连接到PC后创建一个新的java项目。 我将.apk文件导入到项目中,然后设置所需的功能。我的代码中没有任何错误。启动appium后,我运行代码,得到以下错误: 下面是我的代码:

  • 我最近开始从事一个从github克隆的项目。 每次尝试启动rails服务器时,都会出现以下错误: 我的同事也在做这个项目,启动服务器似乎没有任何问题。他正在运行和我一样版本的ruby,rails和WeBrick。 我已尝试将语法从key:更改为:key= 我已经厌倦了多次完全移除和重新安装rvm、ruby和rails,但都没有成功。我也尝试过运行bundle安装,但没有任何帮助。 有人知道出了什么

  • 问题内容: 尝试在ipython Notebook中使用Selenium打开Firefox时出现错误。我环顾四周,发现了类似的错误,但没有与我得到的错误完全匹配的错误。有人知道问题可能是什么以及我如何解决?我正在使用Firefox 22。 我输入的代码如下: 代码返回的错误如下: 问题答案: 尝试在初始化时指定Firefox二进制文件 FirefoxDriver查找的默认路径为。参见Firefox

  • JAVAlang.RuntimeException:无法启动活动组件信息{com.MediaPlayer/com.MediaPlayer.MainActivity}:java。lang.SecurityException:权限拒绝:读取com。Android提供者。媒体MediaProviderURI content://media/external/audio/media from pid=18

  • 我已经读过类似的问题,所以,没有答案张贴,此外,我的错误确实似乎是不同的细节。 当我跑的时候 我收到以下错误: 我正在、和上运行,所以我不认为这是一个版本问题。我猜它可能是部分,在那里它正在寻找浏览器。