无法创建一个新的会话。 (原始错误:需要以下所需的功能,但没有提供:PlatformName,DeviceName)’

发布于 2025-01-21 22:48:59 字数 1443 浏览 0 评论 0原文

这是我的Java代码:

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;

  public class AppiumCapabilities {
  @Test
  public void testAppium() throws MalformedURLException{
  AndroidDriver driver;
  DesiredCapabilities capability = new DesiredCapabilities();
  capability.setCapability("platformName", "Android");
  capability.setCapability("deviceName", "Nexus 5");
  capability.setCapability("udid","039e8ae813aa787d");
  capability.setCapability("platformVersion", "6.0.1");
  File file = new File("C:\\Users\\ShahreenMushtaq\\workspace1\\Appium\\zameenapk\\app-zameen- 
  live-release.apk");
  capability.setCapability("app", file.getAbsolutePath());
  driver = new AndroidDriver(new URL("http://192.168.100.12:4723/wd/hub"),capability);
  }
 }

错误:

info:[debug]以错误:{“状态”:33,“ value”:{“消息”:“无法创建一个新的会话。(原始错误:需要以下所需的功能,但没有提供:PlatformName,deviceName)”,“ Origvalue”:“需要以下所需的功能,但没有提供:PlatformName,deviceName“},“ sessionId”:null} 信息:< - POST/WD/HUB/SESSION 500 3.228 MS -314

我已经在现有会话中重新启动了Appium。我的appium设置如下所示:

“

Here is my Java code:

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;

  public class AppiumCapabilities {
  @Test
  public void testAppium() throws MalformedURLException{
  AndroidDriver driver;
  DesiredCapabilities capability = new DesiredCapabilities();
  capability.setCapability("platformName", "Android");
  capability.setCapability("deviceName", "Nexus 5");
  capability.setCapability("udid","039e8ae813aa787d");
  capability.setCapability("platformVersion", "6.0.1");
  File file = new File("C:\\Users\\ShahreenMushtaq\\workspace1\\Appium\\zameenapk\\app-zameen- 
  live-release.apk");
  capability.setCapability("app", file.getAbsolutePath());
  driver = new AndroidDriver(new URL("http://192.168.100.12:4723/wd/hub"),capability);
  }
 }

Error:

info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: The following desired capabilities are required, but were not provided: platformName, deviceName)","origValue":"The following desired capabilities are required, but were not provided: platformName, deviceName"},"sessionId":null}
info: <-- POST /wd/hub/session 500 3.228 ms - 314

I have already restarted the Appium with Override Existing Session. My Appium settings are shown below:

Appium Settings

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文