公共类 ChromeBrowserLaunch {AppiumDriver 驱动程序;public static void main(String[] args) 抛出 MalformedURLException {DesiredCapabilities cap = new DesiredCapabilities();cap.setCapability(MobileCapabilityType.DEVICE_NAME,像素");cap.setCapability(MobileCapabilityType.VERSION, "8.0");cap.setCapability(MobileCapabilityType.PLATFORM_NAME,Android");cap.setCapability(MobileCapabilityType.BROWSER_NAME,Chrome");cap.setCapability("chromedriverExecutable", "D:\\chromedriver\\chromedriver\\chromedriver.exe");driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), cap);driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);driver.get("http://facebook.com");driver.findElementByXPath("///*[@id=\"m_login_email\"]").sendKeys("geeta");driver.findElementByXPath("///*[@id='m_login_password']").sendKeys("geeta");驱动程序隐藏键盘();driver.findElement(By.id("signup-button")).click();}}线程main"中的异常org.openqa.selenium.SessionNotCreatedException:无法创建新的远程会话.请检查服务器日志以获取更多详细信息.原来的错误:处理时发生未知的服务器端错误命令.原始错误:无法创建新会话.细节:会话未创建:此版本的 ChromeDriver 仅支持 Chrome版本 83构建信息:版本:'3.141.59',修订版:'e82be7d358',时间:'2018-11-14T08:17:03'系统信息:主机:'DESKTOP-R5U0RRK',ip:'192.168.0.106',os.name:'Windows 10',os.arch:'amd64',os.version:'10.0',java.version: '1.8.0_231'驱动程序信息:driver.version:AndroidDriver远程堆栈跟踪:UnknownError:处理命令时发生未知的服务器端错误.原始错误:新会话无法创建.详细信息:会话未创建:此版本的ChromeDriver 仅支持 Chrome 83 版在 getResponseForW3CError (C:\Users\admin\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\errors.js:804:9)在 asyncHandler (C:\Users\admin\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:388:37)在 process._tickCallback (internal/process/next_tick.js:68:7)构建信息:版本:'3.141.59',修订版:'e82be7d358',时间:'2018-11-14T08:17:03'系统信息:主机:'DESKTOP-R5U0RRK',ip:'192.168.0.106',os.name:'Windows 10',os.arch:'amd64',os.version:'10.0',java.version: '1.8.0_231' 解决方案 Android 上的 Chrome 浏览器具有包名称 com.android.chrome 和活动名称 com.google.android.apps.chrome.Main在 Appium 中,您不需要浏览器可执行文件来打开像 Selenium 这样的浏览器,因此只需添加 .APP_PACKAGE 和 .APP_ACTIVITY,就像这样:cap.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "com.android.chrome");cap.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, "com.google.android.apps.chrome.Main");以下导入:import io.appium.java_client.remote.AndroidMobileCapabilityType;从您的代码中删除这一行:cap.setCapability("chromedriverExecutable", "D:\\chromedriver\\chromedriver\\chromedriver.exe");注意:确保设备上安装了 Chrome 浏览器.参考:如何查找您的应用的appPackage和appActivity名称someone please help me to resolve this issue. Thanks in advance.While running java code to open chrome browser in Emulator, I am getting "Failed to start Chromedriver session: A new session could not be created. Details: session not created: This version of ChromeDriver only supports Chrome version 83" error message.public class ChromeBrowserLaunch { AppiumDriver driver; public static void main(String[] args) throws MalformedURLException { DesiredCapabilities cap = new DesiredCapabilities(); cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Pixel"); cap.setCapability(MobileCapabilityType.VERSION, "8.0"); cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android"); cap.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome"); cap.setCapability("chromedriverExecutable", "D:\\chromedriver\\chromedriver\\chromedriver.exe"); driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), cap); driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); driver.get("http://facebook.com"); driver.findElementByXPath("//*[@id=\"m_login_email\"]").sendKeys("geeta"); driver.findElementByXPath("//*[@id='m_login_password']").sendKeys("geeta"); driver.hideKeyboard(); driver.findElement(By.id("signup-button")).click(); }} Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: A new session could not be created. Details: session not created: This version of ChromeDriver only supports Chrome version 83 Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'DESKTOP-R5U0RRK', ip: '192.168.0.106', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_231' Driver info: driver.version: AndroidDriver remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: A new session could not be created. Details: session not created: This version of ChromeDriver only supports Chrome version 83 at getResponseForW3CError (C:\Users\admin\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\errors.js:804:9) at asyncHandler (C:\Users\admin\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:388:37) at process._tickCallback (internal/process/next_tick.js:68:7) Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'DESKTOP-R5U0RRK', ip: '192.168.0.106', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_231' 解决方案 Chrome browser on Android has the package name com.android.chrome and the name of the activity com.google.android.apps.chrome.MainIn Appium you don't need a browser executable to open a browser like Selenium, so just add .APP_PACKAGE and .APP_ACTIVITY in your capability, like this:cap.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "com.android.chrome");cap.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, "com.google.android.apps.chrome.Main");Following import:import io.appium.java_client.remote.AndroidMobileCapabilityType;Remove this line from your code:cap.setCapability("chromedriverExecutable", "D:\\chromedriver\\chromedriver\\chromedriver.exe");Note: Make sure the chrome browser is installed on the device.Reference : How to find appPackage and appActivity name of your App 这篇关于Chrome 浏览器无法使用 Java 在 Appium 中启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-31 01:23