简体   繁体   English

Appium 错误:线程“main”org.openqa.selenium.SessionNotCreatedException 中的异常:无法创建新的远程会话

[英]Appium Error :Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session

I am new to Appium.我是 Appium 的新手。 I am trying to run a test using Appium test case on my Android emulator to open Chrome browser and search for "google.com"我正在尝试在我的 Android 模拟器上使用 Appium 测试用例运行测试以打开 Chrome 浏览器并搜索“google.com”

I have tried many things to resolve my issue:我尝试了很多方法来解决我的问题:

1.update chrome on my Android emulator browser 1.在我的Android模拟器浏览器上更新chrome

2.update the Maven dependencies and the java client 2.更新Maven依赖和java客户端

3.restarting appium server. 3.重启appium服务器。

and many things more还有很多事情

I am attaching both pics and posting the code for easier analyzing of the problem.我附上了两张图片并发布了代码以便于分析问题。

TestWebBrowser.java Code: TestWebBrowser.java 代码:

public static AppiumDriver<MobileElement> driver; 
public static void main(String[] args) throws MalformedURLException  {

DesiredCapabilities capabilities = new DesiredCapabilities();   
capabilities.setCapability(CapabilityType.BROWSER_NAME, "Chrome");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Test_Demo");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "7.1.1");
driver = new AndroidDriver<MobileElement> (new URL("https://127.0.0.1:4723/wd/hub"), capabilities);
driver.get("http://google.com");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.quit();
}

POM.xml Appium dependency used:使用的 POM.xml Appium 依赖项:

<dependencies>
<dependency>
  <groupId>io.appium</groupId>
  <artifactId>java-client</artifactId>
  <version>7.0.0</version>
</dependency>
</dependencies>

Error Description below (thought a pic would be better than copy-paste of the error):下面的错误描述(认为图片比复制粘贴错误更好): eclipse 控制台中的错误描述

Please let me know if I am doing anything fundamentally wrong.如果我在做任何根本错误的事情,请告诉我。 It might be a noob mistake.这可能是一个菜鸟错误。 But couldn't find much help with the other stackoverflow questions.但在其他 stackoverflow 问题上找不到太多帮助。

In your JAVA code did you add Selenium Jars?在您的 JAVA 代码中,您是否添加了 Selenium Jars? If not then add all selenium Jars and try again, it will work.如果没有,则添加所有硒罐并重试,它将起作用。

Selenium Jars are commonly used for web automation but for Android automation and desired capabilities we require some aspects of web as well, hence selenium Jars must be used in Android Automation. Selenium Jars 通常用于 Web 自动化,但对于 Android 自动化和所需的功能,我们也需要 Web 的某些方面,因此必须在 Android 自动化中使用 selenium Jars。

Following dependencies are required for appium: appium 需要以下依赖项:

  1. java-client java客户端
  2. selenium-java硒-java

Please add the following dependencies in your pom.xml file:请在您的 pom.xml 文件中添加以下依赖项:

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.141.59</version>
</dependency>

<!-- https://mvnrepository.com/artifact/io.appium/java-client -->
<dependency>
    <groupId>io.appium</groupId>
    <artifactId>java-client</artifactId>
    <version>7.0.0</version>
</dependency>

Also make sure your appium server is running in 127.0.0.1:4723还要确保您的 appium 服务器在 127.0.0.1:4723 中运行

Check your virtual device version if its Android-Version is 9.0+.如果其 Android 版本为 9.0+,请检查您的虚拟设备版本。 Then create another device with a version equal to Android 9(Pie) or less than that and try it again.然后创建另一个版本等于或低于 Android 9(Pie) 的设备,然后再试一次。 As the latest android version is causing some issues so I tried it with Android 9 which works for me.由于最新的 android 版本导致了一些问题,所以我尝试了对我有用的 Android 9。 In the same way, don't go for the latest device as well.同样,也不要选择最新的设备。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Selenium 3.0 Firefx 驱动程序因 org.openqa.selenium.SessionNotCreatedException 失败:无法创建新的远程会话 - Selenium 3.0 Firefx Driver fails with org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session WinAppDriver:org.openqa.selenium.SessionNotCreatedException:无法创建新的远程 session - WinAppDriver: org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session org.openqa.selenium.SessionNotCreatedException:无法创建新的远程会话。 在模拟器中初始化android驱动程序 - org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. while initializing android driver in emulator org.openqa.selenium.SessionNotCreatedException:无法在Mac中创建新的远程会话 - org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session in Mac org.openqa.selenium.SessionNotCreatedException:无法通过 Selenium 和 Java 使用 GeckoDriver 和 Firefox 创建会话错误 - org.openqa.selenium.SessionNotCreatedException: Unable to create session error using GeckoDriver and Firefox through Selenium and Java org.openqa.selenium.SessionNotCreatedException 与 Appium - org.openqa.selenium.SessionNotCreatedException with Appium Appium _org.openqa.selenium.SessionNotCreatedException - Appium _org.openqa.selenium.SessionNotCreatedException org.openqa.selenium.SessionNotCreatedException:会话未为Chrome创建异常 - org.openqa.selenium.SessionNotCreatedException: session not created exception for Chrome 线程“主” org.openqa.selenium.SessionNotCreatedException中的异常:无法启动浏览器 - Exception in thread “main” org.openqa.selenium.SessionNotCreatedException: Failed to start browser org.openqa.selenium.SessionNotCreatedException:会话未创建断开连接:无法使用 ChromeDriver 和 Chrome 将消息发送到渲染器错误 - org.openqa.selenium.SessionNotCreatedException: session not created disconnected:unable to send message to renderer error with ChromeDriver and Chrome
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM